[libcxx-commits] [libcxx] [libc++] Implement P2538R1 "ADL-proof std::projected" (PR #65411)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 6 06:01:39 PDT 2023
================
@@ -23,13 +23,29 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
-template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj>
-struct projected {
- using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
- indirect_result_t<_Proj&, _It> operator*() const; // not defined
+template <class _It, class _Proj>
+struct __projected_impl {
+ struct __type {
+ using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
+ indirect_result_t<_Proj&, _It> operator*() const; // not defined
+ };
};
-template<weakly_incrementable _It, class _Proj>
+template <weakly_incrementable _It, class _Proj>
+struct __projected_impl<_It, _Proj> {
+ struct __type {
+ using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
+ using difference_type = iter_difference_t<_It>;
+ indirect_result_t<_Proj&, _It> operator*() const; // not defined
+ };
+};
+
+// Note: We implement std::projected in a way that satisfies P2538R1 even in standard
+// modes before C++26 to avoid breaking the ABI between standard modes.
+template <indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj>
+using projected = typename __projected_impl<_It, _Proj>::__type;
+
+template <weakly_incrementable _It, class _Proj>
struct incrementable_traits<projected<_It, _Proj>> {
using difference_type = iter_difference_t<_It>;
};
----------------
ldionne wrote:
Yeah it should be removed, thanks for the heads up. I basically just took https://reviews.llvm.org/D119029 and did a few changes I could spot, uploaded it here and closed the Phab revision. I'll address this.
https://github.com/llvm/llvm-project/pull/65411
More information about the libcxx-commits
mailing list