[Bug libstdc++/114400] The resolution of LWG3950 seems incorrectly implemented
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 20 09:16:23 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114400
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
One option would be to make __type_identity_t an alias for type_identity_t in
C++20:
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -156,13 +156,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using __conditional_t
= typename __conditional<_Cond>::template type<_If, _Else>;
+#ifdef __cpp_lib_type_identity // C++ >= 20
+ /** * Identity metafunction.
+ * @since C++20
+ * @{
+ */
+ template<typename _Tp>
+ struct type_identity { using type = _Tp; };
+
+ template<typename _Tp>
+ using type_identity_t = typename type_identity<_Tp>::type;
+ /// @}
+
+ template<typename _Tp>
+ using __type_identity_t = type_identity_t<_Tp>;
+ template<typename _Tp>
+ using __type_identity_t = type_identity_t<_Tp>;
+#else
/// @cond undocumented
template <typename _Type>
- struct __type_identity
- { using type = _Type; };
+ using __type_identity = type_identity<_Type>;
template<typename _Tp>
using __type_identity_t = typename __type_identity<_Tp>::type;
+#endif
namespace __detail
{
@@ -3600,19 +3617,6 @@ template<typename _Ret, typename _Fn, typename... _Args>
/// @}
#endif // __cpp_lib_remove_cvref
-#ifdef __cpp_lib_type_identity // C++ >= 20
- /** * Identity metafunction.
- * @since C++20
- * @{
- */
- template<typename _Tp>
- struct type_identity { using type = _Tp; };
-
- template<typename _Tp>
- using type_identity_t = typename type_identity<_Tp>::type;
- /// @}
-#endif
-
#ifdef __cpp_lib_unwrap_ref // C++ >= 20
/** Unwrap a reference_wrapper
* @since C++20
I don't think we have any uses of __type_identity or __type_identity_t where
this will cause ABI changes. None of the types using __type_identity_t in
constructors are explicitly instantiated in the library.
More information about the Gcc-bugs
mailing list