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