[libcxx-commits] [PATCH] D132327: [libc++] Implement P2445R1 (`std::forward_like`)
Hui via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Aug 21 12:37:59 PDT 2022
huixie90 requested changes to this revision.
huixie90 added inline comments.
This revision now requires changes to proceed.
================
Comment at: libcxx/include/__utility/forward_like.h:26-27
+template <class _Tp, class _Utp>
+[[nodiscard]] constexpr auto&& forward_like(_Utp&& __ux) noexcept {
+ static_assert(__can_reference<_Tp>, "std::forward_like's first template argument must be a referenceable type.");
+
----------------
The standard spec has a trailing return type, meaning if the return type is ill formed, the function should be SFINAE out.
I think we should keep what is in the spec rather than hard error in the function body
================
Comment at: libcxx/test/std/utilities/utility/forward_like/forward_like.msvc/test.compile.pass.cpp:72-82
+constexpr bool test() {
+ int val = 1729;
+ auto&& result = forward_like<const double&>(val);
+ static_assert(is_same_v<decltype(result), const int&>);
+ assert(&result == &val);
+ return true;
+}
----------------
I think it should also run the test at runtime and the `test()` should also test all different combinations.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132327/new/
https://reviews.llvm.org/D132327
More information about the libcxx-commits
mailing list