[libcxx-commits] [PATCH] D115100: [libc++] Enable the optimized _IsSame on GCC as well as Clang.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 6 07:31:18 PST 2021


ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.


================
Comment at: libcxx/include/tuple:1120
+template <class ..._Ts>
+struct __all_are_swappable : __all<__is_swappable<_Ts>::value...> {};
+
----------------
Instead, I really feel like we could redefine `__all` to be:

```
template <bool ..._Pred>
struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>> { };
```

After all, we will generally instantiate `__all` with several types, however we probably won't instantiate `__all` itself several times. What I'm trying to say is that since `__all` is variadic, we will probably instantiate it some factor less than the number of types that we're passing into it, so it might be reasonable to define it as a `struct` despite the additional costs. That would fix our mangling problem without needing a definition for `__all_are_swappable`, which IMO is kind of weird.


================
Comment at: libcxx/include/type_traits:553
 
-#if __has_keyword(__is_same)
+#if __has_builtin(__is_same)
 
----------------
Do we support any compilers where this is false? I don't think so -- we could probably just drop the `#if` altogether.


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

https://reviews.llvm.org/D115100



More information about the libcxx-commits mailing list