declval.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. template <class _Tp>
  24. _LIBCPP_HIDE_FROM_ABI decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT {
  25. static_assert(!__is_same(_Tp, _Tp),
  26. "std::declval can only be used in an unevaluated context. "
  27. "It's likely that your current usage is trying to extract a value from the function.");
  28. }
  29. _LIBCPP_END_NAMESPACE_STD
  30. #endif // _LIBCPP___UTILITY_DECLVAL_H