brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 02dde2b Raw
66 lines · c
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___FUNCTIONAL_IDENTITY_H11#define _LIBCPP___FUNCTIONAL_IDENTITY_H12 13#include <__config>14#include <__fwd/functional.h>15#include <__type_traits/integral_constant.h>16#include <__utility/forward.h>17 18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#  pragma GCC system_header20#endif21 22_LIBCPP_BEGIN_NAMESPACE_STD23 24template <class _Tp>25struct __is_identity : false_type {};26 27struct __identity {28  template <class _Tp>29  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT {30    return std::forward<_Tp>(__t);31  }32 33  using is_transparent = void;34};35 36template <>37struct __is_identity<__identity> : true_type {};38template <>39struct __is_identity<reference_wrapper<__identity> > : true_type {};40template <>41struct __is_identity<reference_wrapper<const __identity> > : true_type {};42 43#if _LIBCPP_STD_VER >= 2044 45struct identity {46  template <class _Tp>47  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_LIBCPP_LIFETIMEBOUND _Tp&& __t) const noexcept {48    return std::forward<_Tp>(__t);49  }50 51  using is_transparent = void;52};53 54template <>55struct __is_identity<identity> : true_type {};56template <>57struct __is_identity<reference_wrapper<identity> > : true_type {};58template <>59struct __is_identity<reference_wrapper<const identity> > : true_type {};60 61#endif // _LIBCPP_STD_VER >= 2062 63_LIBCPP_END_NAMESPACE_STD64 65#endif // _LIBCPP___FUNCTIONAL_IDENTITY_H66