1 // Copyright Daniel Wallin 2006.
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)
7 #ifndef BOOST_PARAMETER_TEMPLATE_KEYWORD_HPP
8 #define BOOST_PARAMETER_TEMPLATE_KEYWORD_HPP
10 #include <boost/parameter/aux_/template_keyword.hpp>
11 #include <boost/parameter/config.hpp>
13 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
14 #include <boost/mp11/integral.hpp>
15 #include <boost/mp11/utility.hpp>
16 #include <type_traits>
18 #include <boost/mpl/bool.hpp>
19 #include <boost/mpl/if.hpp>
20 #include <boost/mpl/eval_if.hpp>
21 #include <boost/mpl/identity.hpp>
22 #include <boost/type_traits/add_lvalue_reference.hpp>
23 #include <boost/type_traits/is_function.hpp>
24 #include <boost/type_traits/is_array.hpp>
27 namespace boost { namespace parameter {
29 template <typename Tag, typename T>
30 struct template_keyword : ::boost::parameter::aux::template_keyword_base
35 // reference is needed for two reasons:
37 // 1. It is used in the body of arg_list<...>
39 // 2. It is the result of binding<...>, which we mistakenly told
40 // people to use instead of value_type<...> to access named
41 // template parameters
43 // It used to be that reference == value_type, but that broke when
44 // the argument was a function or array type, because various
45 // arg_list functions return reference.
47 // Simply making reference == value_type& would break all the
48 // legacy code that uses binding<...> to access named template
49 // parameters. -- David Abrahams
50 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
51 using reference = typename ::boost::mp11::mp_eval_if<
53 ::std::is_function<value_type>
54 , ::boost::mp11::mp_true
55 , ::std::is_array<value_type>
57 , ::std::add_lvalue_reference<value_type>
58 , ::boost::mp11::mp_identity
62 typedef typename ::boost::mpl::eval_if<
63 typename ::boost::mpl::if_<
64 ::boost::is_function<value_type>
66 , ::boost::is_array<value_type>
68 , ::boost::add_lvalue_reference<value_type>
69 , ::boost::mpl::identity<value_type>
71 #endif // BOOST_PARAMETER_CAN_USE_MP11
73 }} // namespace boost::parameter
75 #define BOOST_PARAMETER_TEMPLATE_KEYWORD(name) \
80 template <typename T> \
81 struct name : ::boost::parameter::template_keyword<tag::name,T> \
86 #endif // include guard