aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2025-04-22 12:52:34 -0400
committerPatrick Palka <ppalka@redhat.com>2025-04-22 12:52:34 -0400
commit49e79b86936373fc70c3bdea3b2d8353cf8957b1 (patch)
treee5871923100116bcac2f0c42f2e2422242c604bf
parenta544a9c5bbfce013ab020f82acd2470d610fb3c8 (diff)
downloadgcc-49e79b86936373fc70c3bdea3b2d8353cf8957b1.zip
gcc-49e79b86936373fc70c3bdea3b2d8353cf8957b1.tar.gz
gcc-49e79b86936373fc70c3bdea3b2d8353cf8957b1.tar.bz2
Revert "libstdc++: Optimize std::projected<I, std::identity>" [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.
-rw-r--r--libstdc++-v3/include/bits/iterator_concepts.h5
-rw-r--r--libstdc++-v3/testsuite/24_iterators/indirect_callable/projected.cc5
2 files changed, 0 insertions, 10 deletions
diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h
index e36556d..3b73ff9 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<typename _Iter>
- 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 0b18616..e2fbf7d 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<typename T>
using PI = std::projected<T, std::identity>;
-#if __GLIBCXX__
-// Verify our projected<I, identity> optimization.
-static_assert(std::same_as<PI<int*>, int*>);
-#else
static_assert(std::same_as<PI<int*>::value_type, int>);
-#endif
static_assert(std::same_as<decltype(*std::declval<const PI<int*>&>()), int&>);
struct X