declval.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // common_type.hpp ---------------------------------------------------------//
  2. // Copyright 2010 Vicente J. Botet Escriba
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_EX_TYPE_TRAITS_EXT_DECLVAL__HPP
  6. #define BOOST_EX_TYPE_TRAITS_EXT_DECLVAL__HPP
  7. #include <boost/config.hpp>
  8. //----------------------------------------------------------------------------//
  9. #include "add_rvalue_reference.hpp"
  10. //----------------------------------------------------------------------------//
  11. // //
  12. // C++03 implementation of //
  13. // Written by Vicente J. Botet Escriba //
  14. //~ 20.3.4 Function template declval [declval]
  15. //~ 1 The library provides the function template declval to simplify the definition of expressions which occur as
  16. //~ unevaluated operands.
  17. //~ 2 Remarks: If this function is used, the program is ill-formed.
  18. //~ 3 Remarks: The template parameter T of declval may be an incomplete type.
  19. //~ [ Example:
  20. //~ template <class To, class From>
  21. //~ decltype(static_cast<To>(declval<From>())) convert(From&&);
  22. //~ declares a function template convert which only participats in overloading if the type From can be
  23. //~ explicitly converted to type To. For another example see class template common_type (20.7.6.6). -end
  24. //~ example ]
  25. // //
  26. //----------------------------------------------------------------------------//
  27. namespace boost_ex {
  28. template <typename T>
  29. typename add_rvalue_reference<T>::type declval(); //noexcept; // as unevaluated operand
  30. } // namespace boost
  31. #endif // BOOST_EX_TYPE_TRAITS_EXT_DECLVAL__HPP