[libcxx-commits] [PATCH] D58987: Make underlying_type SFINAE-friendly

Eric Fiselier via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 6 14:48:33 PST 2019


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


================
Comment at: include/type_traits:4724
+template <class _Tp>
+struct underlying_type: __impl_underlying_type<_Tp> { };
+
----------------
Nit. Space between `underlying_type` and `:`.


================
Comment at: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.fail.cpp:22
+{
+	test_sfinae(0); // expected-error {{no matching function for call to 'test_sfinae'}}
+
----------------
No need to get SFINAE involved here. Simply write:

```
int main() {
  using T = std::underlying_type<int>::type; // expected-error {{boom}}
}
```


================
Comment at: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp:30
 
+template<class T>
+std::enable_if_t<
----------------
I'm not sure what this test is actually testing. How about:

```
template <class T, class = typename std::underlying_type<T>::type>
std::true_type test_sfinae(int);
template <class T>
std::false_type test_sfinae(...);

int main() {
  static_assert(decltype(test_sfinae<int>(0))::value == false, "not an enum");
   static_assert(decltype(test_sfinae<E>(0))::value == true, "is an enum");

}
```


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

https://reviews.llvm.org/D58987





More information about the libcxx-commits mailing list