File indexing completed on 2026-05-03 08:13:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___FUNCTIONAL_IDENTITY_H
0011 #define _LIBCPP___FUNCTIONAL_IDENTITY_H
0012
0013 #include <__config>
0014 #include <__fwd/functional.h>
0015 #include <__type_traits/integral_constant.h>
0016 #include <__utility/forward.h>
0017
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 # pragma GCC system_header
0020 #endif
0021
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023
0024 template <class _Tp>
0025 struct __is_identity : false_type {};
0026
0027 struct __identity {
0028 template <class _Tp>
0029 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT {
0030 return std::forward<_Tp>(__t);
0031 }
0032
0033 using is_transparent = void;
0034 };
0035
0036 template <>
0037 struct __is_identity<__identity> : true_type {};
0038 template <>
0039 struct __is_identity<reference_wrapper<__identity> > : true_type {};
0040 template <>
0041 struct __is_identity<reference_wrapper<const __identity> > : true_type {};
0042
0043 #if _LIBCPP_STD_VER >= 20
0044
0045 struct identity {
0046 template <class _Tp>
0047 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept {
0048 return std::forward<_Tp>(__t);
0049 }
0050
0051 using is_transparent = void;
0052 };
0053
0054 template <>
0055 struct __is_identity<identity> : true_type {};
0056 template <>
0057 struct __is_identity<reference_wrapper<identity> > : true_type {};
0058 template <>
0059 struct __is_identity<reference_wrapper<const identity> > : true_type {};
0060
0061 #endif
0062
0063 _LIBCPP_END_NAMESPACE_STD
0064
0065 #endif