From 63bda370eddf091c456cea3df82e0e5aa9a1fa97 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Tue, 22 Apr 2025 12:55:05 -0400 Subject: [PATCH] Revert "libstdc++: Optimize std::projected" [PR119888] This non-standard optimization breaks real-world code that expects the result of std::projected to always (be a class type and) have a value_type member, which isn't true for e.g. I=int*, so revert it for now. PR libstdc++/119888 This reverts commit 51761c50f843d5be4e24172535e4524b5072f24c. --- libstdc++-v3/include/bits/iterator_concepts.h | 5 ----- .../testsuite/24_iterators/indirect_callable/projected.cc | 5 ----- 2 files changed, 10 deletions(-) diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h index e36556dc5121..3b73ff9b6b59 100644 --- a/libstdc++-v3/include/bits/iterator_concepts.h +++ b/libstdc++-v3/include/bits/iterator_concepts.h @@ -829,11 +829,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __projected_Proj = _Proj; }; }; - - // Optimize the common case of the projection being std::identity. - template - struct __projected<_Iter, identity> - { using __type = _Iter; }; } // namespace __detail /// [projected], projected diff --git a/libstdc++-v3/testsuite/24_iterators/indirect_callable/projected.cc b/libstdc++-v3/testsuite/24_iterators/indirect_callable/projected.cc index 0b18616aa8b7..e2fbf7dccb9c 100644 --- a/libstdc++-v3/testsuite/24_iterators/indirect_callable/projected.cc +++ b/libstdc++-v3/testsuite/24_iterators/indirect_callable/projected.cc @@ -22,12 +22,7 @@ template using PI = std::projected; -#if __GLIBCXX__ -// Verify our projected optimization. -static_assert(std::same_as, int*>); -#else static_assert(std::same_as::value_type, int>); -#endif static_assert(std::same_as&>()), int&>); struct X -- 2.47.2