unwrap_ref.h 1.5 KB

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