declval.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // declval.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_TYPE_TRAITS_DECLVAL_HPP_INCLUDED
  6. #define BOOST_TYPE_TRAITS_DECLVAL_HPP_INCLUDED
  7. #include <boost/config.hpp>
  8. //----------------------------------------------------------------------------//
  9. #include <boost/type_traits/add_rvalue_reference.hpp>
  10. //----------------------------------------------------------------------------//
  11. // //
  12. // C++03 implementation of //
  13. // 20.2.4 Function template declval [declval] //
  14. // Written by Vicente J. Botet Escriba //
  15. // //
  16. // 1 The library provides the function template declval to simplify the
  17. // definition of expressions which occur as unevaluated operands.
  18. // 2 Remarks: If this function is used, the program is ill-formed.
  19. // 3 Remarks: The template parameter T of declval may be an incomplete type.
  20. // [ Example:
  21. //
  22. // template <class To, class From>
  23. // decltype(static_cast<To>(declval<From>())) convert(From&&);
  24. //
  25. // declares a function template convert which only participates in overloading
  26. // if the type From can be explicitly converted to type To. For another example
  27. // see class template common_type (20.9.7.6). -end example ]
  28. //----------------------------------------------------------------------------//
  29. namespace boost {
  30. template <typename T>
  31. typename add_rvalue_reference<T>::type declval() BOOST_NOEXCEPT; // as unevaluated operand
  32. } // namespace boost
  33. #endif // BOOST_TYPE_TRAITS_DECLVAL_HPP_INCLUDED