unwrap_ref.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
  9. #define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
  10. #include <__config>
  11. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  12. # pragma GCC system_header
  13. #endif
  14. _LIBCPP_BEGIN_NAMESPACE_STD
  15. template <class _Tp>
  16. struct __unwrap_reference { typedef _LIBCPP_NODEBUG _Tp type; };
  17. template <class _Tp>
  18. class reference_wrapper;
  19. template <class _Tp>
  20. struct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG _Tp& type; };
  21. template <class _Tp>
  22. struct decay;
  23. #if _LIBCPP_STD_VER > 17
  24. template <class _Tp>
  25. struct unwrap_reference : __unwrap_reference<_Tp> { };
  26. template <class _Tp>
  27. using unwrap_reference_t = typename unwrap_reference<_Tp>::type;
  28. template <class _Tp>
  29. struct unwrap_ref_decay : unwrap_reference<typename decay<_Tp>::type> { };
  30. template <class _Tp>
  31. using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;
  32. #endif // > C++17
  33. template <class _Tp>
  34. struct __unwrap_ref_decay
  35. #if _LIBCPP_STD_VER > 17
  36. : unwrap_ref_decay<_Tp>
  37. #else
  38. : __unwrap_reference<typename decay<_Tp>::type>
  39. #endif
  40. { };
  41. _LIBCPP_END_NAMESPACE_STD
  42. #endif // _LIBCPP___FUNCTIONAL_UNWRAP_REF_H