Path: blob/main/contrib/llvm-project/libcxx/include/__functional/identity.h
35260 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___FUNCTIONAL_IDENTITY_H10#define _LIBCPP___FUNCTIONAL_IDENTITY_H1112#include <__config>13#include <__fwd/functional.h>14#include <__type_traits/integral_constant.h>15#include <__utility/forward.h>1617#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18# pragma GCC system_header19#endif2021_LIBCPP_BEGIN_NAMESPACE_STD2223template <class _Tp>24struct __is_identity : false_type {};2526struct __identity {27template <class _Tp>28_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT {29return std::forward<_Tp>(__t);30}3132using is_transparent = void;33};3435template <>36struct __is_identity<__identity> : true_type {};37template <>38struct __is_identity<reference_wrapper<__identity> > : true_type {};39template <>40struct __is_identity<reference_wrapper<const __identity> > : true_type {};4142#if _LIBCPP_STD_VER >= 204344struct identity {45template <class _Tp>46[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept {47return std::forward<_Tp>(__t);48}4950using is_transparent = void;51};5253template <>54struct __is_identity<identity> : true_type {};55template <>56struct __is_identity<reference_wrapper<identity> > : true_type {};57template <>58struct __is_identity<reference_wrapper<const identity> > : true_type {};5960#endif // _LIBCPP_STD_VER >= 206162_LIBCPP_END_NAMESPACE_STD6364#endif // _LIBCPP___FUNCTIONAL_IDENTITY_H656667