1// Copyright Frank Mori Hess 2009.
2// Copyright Cromwell D. Enage 2017.
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#include <boost/parameter/template_keyword.hpp>
8#include <boost/parameter/parameters.hpp>
9#include <boost/parameter/required.hpp>
10#include <boost/parameter/value_type.hpp>
11#include <boost/parameter/config.hpp>
12
13#if defined(BOOST_PARAMETER_CAN_USE_MP11) && \
14 BOOST_WORKAROUND(BOOST_MSVC, < 1920)
15#include <type_traits>
16#else
17#include <boost/mpl/bool.hpp>
18#include <boost/mpl/if.hpp>
19#include <boost/type_traits/is_same.hpp>
20#endif
21
22namespace test {
23 namespace keywords {
24
25 BOOST_PARAMETER_TEMPLATE_KEYWORD(function_type)
26 } // namespace keywords
27
28 template <typename K, typename A>
29#if BOOST_WORKAROUND(BOOST_MSVC, < 1920)
30#if defined(BOOST_PARAMETER_CAN_USE_MP11)
31 using X = boost::parameter::value_type<
32#else
33 struct X
34 : boost::parameter::value_type<
35#endif
36 typename boost::parameter::parameters<
37 boost::parameter::required<K>
38 >::BOOST_NESTED_TEMPLATE bind<A>::type
39 , K
40#if defined(BOOST_PARAMETER_CAN_USE_MP11)
41 >;
42#else
43 >
44 {
45 };
46#endif
47#else // MSVC-14.2
48 struct X
49 {
50 typedef typename boost::parameter::value_type<
51 typename boost::parameter::parameters<
52 boost::parameter::required<K>
53 >::BOOST_NESTED_TEMPLATE bind<A>::type
54 , K
55 >::type type;
56 };
57#endif
58
59 template <typename T>
60#if BOOST_WORKAROUND(BOOST_MSVC, < 1920)
61#if defined(BOOST_PARAMETER_CAN_USE_MP11)
62 using Y = std::is_same<
63#else
64 struct Y
65 : boost::mpl::if_<
66 boost::is_same<
67#endif
68 T
69 , typename X<
70 test::keywords::tag::function_type
71 , test::keywords::function_type<T>
72 >::type
73#if defined(BOOST_PARAMETER_CAN_USE_MP11)
74 >;
75#else
76 >
77 , boost::mpl::true_
78 , boost::mpl::false_
79 >::type
80 {
81 };
82#endif
83#else // MSVC-14.2
84 struct Y
85 {
86 typedef typename boost::mpl::if_<
87 boost::is_same<
88 T
89 , typename X<
90 test::keywords::tag::function_type
91 , test::keywords::function_type<T>
92 >::type
93 >
94 , boost::mpl::true_
95 , boost::mpl::false_
96 >::type type;
97 };
98#endif
99
100 struct Z
101 {
102 int operator()() const
103 {
104 return 0;
105 }
106 };
107} // namespace test
108
109#include <boost/mpl/aux_/test.hpp>
110
111#if !defined(BOOST_PARAMETER_CAN_USE_MP11) || \
112 BOOST_WORKAROUND(BOOST_MSVC, >= 1920)
113#include <boost/mpl/assert.hpp>
114#endif
115
116MPL_TEST_CASE()
117{
118#if BOOST_WORKAROUND(BOOST_MSVC, < 1920)
119#if defined(BOOST_PARAMETER_CAN_USE_MP11)
120 static_assert(test::Y<void()>::value, "void()");
121 static_assert(test::Y<test::Z>::value, "test::Z");
122 static_assert(test::Y<double(double)>::value, "double(double)");
123#else
124 BOOST_MPL_ASSERT((test::Y<void()>));
125 BOOST_MPL_ASSERT((test::Y<test::Z>));
126 BOOST_MPL_ASSERT((test::Y<double(double)>));
127#endif
128#else // MSVC-14.2
129 BOOST_MPL_ASSERT((test::Y<void()>::type));
130 BOOST_MPL_ASSERT((test::Y<test::Z>::type));
131 BOOST_MPL_ASSERT((test::Y<double(double)>::type));
132#endif
133}
134
135

source code of boost/libs/parameter/test/function_type_tpl_param.cpp