[libcxx-commits] [PATCH] D97365: [libc++] [C++2b] [P1682] Add to_underlying.

Marek Kurdej via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 4 01:22:22 PST 2021


curdeius marked an inline comment as done.
curdeius added inline comments.


================
Comment at: libcxx/include/utility:1632
+__to_underlying(_Tp __val) noexcept {
+  return static_cast<typename underlying_type<_Tp>::type>(__val);
+}
----------------
zoecarver wrote:
> Nit: you could use `underlying_type_t` here.
I can't, it's C++14 onwards.

```
#if _LIBCPP_STD_VER > 11
template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
#endif
```


================
Comment at: libcxx/test/std/utilities/utility/utility.underlying/to_underlying.fail.cpp:9
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++2a
+
----------------
zoecarver wrote:
> Are we going to retire the `c++2a` alias at some point? Maybe this should be `c++20` instead. 
Hmm, when all compilers we support will accept `-std=c++20`?
IIUC, that's because lit std param is verified by injecting into `-std=...`, so we can't just use `c++20` on a compiler that only accepts `-std=c++2a`.
Maybe there's some clever hack on lit params to translate c++20 into c++2a if the former isn't supported.
But I haven't looked into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97365



More information about the libcxx-commits mailing list