]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Revert "libstdc++: Optimize std::projected<I, std::identity>" [PR119888]
authorPatrick Palka <ppalka@redhat.com>
Tue, 22 Apr 2025 16:52:34 +0000 (12:52 -0400)
committerPatrick Palka <ppalka@redhat.com>
Tue, 22 Apr 2025 16:52:34 +0000 (12:52 -0400)
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
libstdc++-v3/testsuite/24_iterators/indirect_callable/projected.cc

index e36556dc5121e315e1373bbf613161f5f312886d..3b73ff9b6b594a996722551693592b07cfb68d42 100644 (file)
@@ -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
index 0b18616aa8b7394c4d88b91e8365647c88b326bd..e2fbf7dccb9c8cb70878cb1cbc6efbee0b311f74 100644 (file)
 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