[libcxx-commits] [PATCH] D67900: [libc++] Use builtin type traits whenever possible

Richard Smith - zygoloid via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Oct 5 21:09:57 PDT 2019


rsmith added inline comments.


================
Comment at: libcxx/include/type_traits:550
+template <class _Tp, class _Up>
+using is_same = _BoolConstant<__is_same(_Tp, _Up)>;
+
----------------
Nice idea. Is this conforming? Consider this somewhat-contrived example:

```
template<typename T> struct A {
  void f(is_same<T, int>) {}
  void f(is_same<T, float>) {}
  void f(false_type) {}
  void g() { f(disjunction<is_same<T, int>, is_same<T, float>, false_type>()); }
};
```

With a class template `is_same`, `g()` calls the version of `f` corresponding to the "right" option, but with the alias template version, instantiating `A<T>` is ill-formed because multiple signatures of `f` collide.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67900





More information about the libcxx-commits mailing list