declval.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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___UTILITY_DECLVAL_H
  9. #define _LIBCPP___UTILITY_DECLVAL_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. // Suppress deprecation notice for volatile-qualified return type resulting
  16. // from volatile-qualified types _Tp.
  17. _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  18. template <class _Tp>
  19. _Tp&& __declval(int);
  20. template <class _Tp>
  21. _Tp __declval(long);
  22. _LIBCPP_SUPPRESS_DEPRECATED_POP
  23. #ifdef _LIBCPP_COMPILER_MSVC
  24. template <class _Tp>
  25. using __declval_void = void;
  26. template <class _Tp, class = void>
  27. struct __declval_add_rvalue_reference {
  28. using type = _Tp;
  29. };
  30. template <class _Tp>
  31. struct __declval_add_rvalue_reference<_Tp, __declval_void<_Tp&>> {
  32. using type = _Tp&&;
  33. };
  34. #endif
  35. template <class _Tp>
  36. #ifdef _LIBCPP_COMPILER_MSVC
  37. typename __declval_add_rvalue_reference<_Tp>::type
  38. #else
  39. decltype(__declval<_Tp>(0))
  40. #endif
  41. declval() _NOEXCEPT;
  42. _LIBCPP_END_NAMESPACE_STD
  43. #endif // _LIBCPP___UTILITY_DECLVAL_H