williamr@2
|
1 |
// Boost result_of library
|
williamr@2
|
2 |
|
williamr@2
|
3 |
// Copyright Douglas Gregor 2004. Use, modification and
|
williamr@2
|
4 |
// distribution is subject to the Boost Software License, Version
|
williamr@2
|
5 |
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
williamr@2
|
6 |
// http://www.boost.org/LICENSE_1_0.txt)
|
williamr@2
|
7 |
|
williamr@2
|
8 |
// For more information, see http://www.boost.org/libs/utility
|
williamr@2
|
9 |
#ifndef BOOST_RESULT_OF_HPP
|
williamr@2
|
10 |
#define BOOST_RESULT_OF_HPP
|
williamr@2
|
11 |
|
williamr@2
|
12 |
#include <boost/config.hpp>
|
williamr@2
|
13 |
#include <boost/type_traits/ice.hpp>
|
williamr@2
|
14 |
#include <boost/type.hpp>
|
williamr@2
|
15 |
#include <boost/preprocessor.hpp>
|
williamr@2
|
16 |
#include <boost/detail/workaround.hpp>
|
williamr@2
|
17 |
#include <boost/mpl/has_xxx.hpp>
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
williamr@2
|
20 |
# define BOOST_RESULT_OF_NUM_ARGS 10
|
williamr@2
|
21 |
#endif
|
williamr@2
|
22 |
|
williamr@2
|
23 |
namespace boost {
|
williamr@2
|
24 |
|
williamr@2
|
25 |
template<typename F> struct result_of;
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
williamr@2
|
28 |
namespace detail {
|
williamr@2
|
29 |
|
williamr@2
|
30 |
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
williamr@2
|
31 |
|
williamr@2
|
32 |
template<typename F, typename FArgs, bool HasResultType> struct get_result_of;
|
williamr@2
|
33 |
|
williamr@2
|
34 |
template<typename F, typename FArgs>
|
williamr@2
|
35 |
struct get_result_of<F, FArgs, true>
|
williamr@2
|
36 |
{
|
williamr@2
|
37 |
typedef typename F::result_type type;
|
williamr@2
|
38 |
};
|
williamr@2
|
39 |
|
williamr@2
|
40 |
template<typename F, typename FArgs>
|
williamr@2
|
41 |
struct get_result_of<F, FArgs, false>
|
williamr@2
|
42 |
{
|
williamr@2
|
43 |
typedef typename F::template result<FArgs>::type type;
|
williamr@2
|
44 |
};
|
williamr@2
|
45 |
|
williamr@2
|
46 |
template<typename F>
|
williamr@2
|
47 |
struct get_result_of<F, F(void), false>
|
williamr@2
|
48 |
{
|
williamr@2
|
49 |
typedef void type;
|
williamr@2
|
50 |
};
|
williamr@2
|
51 |
|
williamr@2
|
52 |
template<typename F, typename FArgs>
|
williamr@2
|
53 |
struct result_of : get_result_of<F, FArgs, (has_result_type<F>::value)> {};
|
williamr@2
|
54 |
|
williamr@2
|
55 |
} // end namespace detail
|
williamr@2
|
56 |
|
williamr@2
|
57 |
#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
|
williamr@2
|
58 |
#include BOOST_PP_ITERATE()
|
williamr@2
|
59 |
|
williamr@2
|
60 |
#else
|
williamr@2
|
61 |
# define BOOST_NO_RESULT_OF 1
|
williamr@2
|
62 |
#endif
|
williamr@2
|
63 |
|
williamr@2
|
64 |
}
|
williamr@2
|
65 |
|
williamr@2
|
66 |
#endif // BOOST_RESULT_OF_HPP
|