[libcxx-commits] [PATCH] D132327: [libc++] Implement P2445R1 (`std::forward_like`)

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 23 23:54:57 PDT 2022


huixie90 added inline comments.


================
Comment at: libcxx/include/__utility/forward_like.h:37-38
+template <class _Tp, class _Up>
+[[nodiscard]] constexpr auto forward_like(_Up&& __ux) noexcept -> _ForwardLike<_Tp, decltype(__ux)> { 
+   return static_cast<_ForwardLike<_Tp, decltype(__ux)>>(__ux);
+}
----------------
I think the return type is just `_ForwardLike<_Tp, _Up>`


================
Comment at: libcxx/include/utility:45-59
+template <typename T, typename U>
+using __override_ref_t = std::conditional_t<std::is_rvalue_reference_v<T>,
+                                            std::remove_reference_t<U> &&, U &>;
+template <typename T, typename U>
+using __copy_const_t =
+    std::conditional_t<std::is_const_v<std::remove_reference_t<T>>,
+                       U const, U>;
----------------
I think you don't need to put implementation details here. just copy whatever in the standard

```
template<class T, class U>
[[nodiscard]] constexpr auto forward_like(U&& x) noexcept -> see below;        // since C++23
```


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

https://reviews.llvm.org/D132327



More information about the libcxx-commits mailing list