[libcxx-commits] [PATCH] D143071: [libc++] Avoid ODR violations in __exception_guard

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 3 14:25:52 PST 2023


ldionne added inline comments.


================
Comment at: libcxx/include/__utility/exception_guard.h:63
 template <class _Rollback>
 struct __exception_guard {
   __exception_guard() = delete;
----------------
philnik wrote:
> dblaikie wrote:
> > ldionne wrote:
> > > Instead, let's define two classes, one is `__exception_guard_exceptions` and the other one is `__exception_guard_noexceptions`. Then we can have an alias to the right one.
> > If they're going to have separate names with an alias - do they need to be/is it better that they not be preprocessor conditional, and only the definition of the alias would need the preprocessor conditionals? Or is it worth keeping the extra code out of the parsing/worth the extra preprocessor conditionality to do so?
> I left them in the conditional to avoid accidentally depending on one of them directly. This should be caught in code review, but letting the compiler complain makes it more obvious.
FWIW I would have kept only the alias in `#ifdef` to keep the amount of conditional code as small as possible.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143071/new/

https://reviews.llvm.org/D143071



More information about the libcxx-commits mailing list