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)
6
7#ifndef BOOST_PARAMETER_TEMPLATE_KEYWORD_HPP
8#define BOOST_PARAMETER_TEMPLATE_KEYWORD_HPP
9
10#include <boost/parameter/aux_/template_keyword.hpp>
11#include <boost/parameter/config.hpp>
12
13#if defined(BOOST_PARAMETER_CAN_USE_MP11)
14#include <boost/mp11/integral.hpp>
15#include <boost/mp11/utility.hpp>
16#include <type_traits>
17#else
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>
25#endif
26
27namespace boost { namespace parameter {
28
29 template <typename Tag, typename T>
30 struct template_keyword : ::boost::parameter::aux::template_keyword_base
31 {
32 typedef Tag key_type;
33 typedef T value_type;
34
35 // reference is needed for two reasons:
36 //
37 // 1. It is used in the body of arg_list<...>
38 //
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
42 //
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.
46 //
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<
52 ::boost::mp11::mp_if<
53 ::std::is_function<value_type>
54 , ::boost::mp11::mp_true
55 , ::std::is_array<value_type>
56 >
57 , ::std::add_lvalue_reference<value_type>
58 , ::boost::mp11::mp_identity
59 , value_type
60 >::type;
61#else
62 typedef typename ::boost::mpl::eval_if<
63 typename ::boost::mpl::if_<
64 ::boost::is_function<value_type>
65 , ::boost::mpl::true_
66 , ::boost::is_array<value_type>
67 >::type
68 , ::boost::add_lvalue_reference<value_type>
69 , ::boost::mpl::identity<value_type>
70 >::type reference;
71#endif // BOOST_PARAMETER_CAN_USE_MP11
72 };
73}} // namespace boost::parameter
74
75#define BOOST_PARAMETER_TEMPLATE_KEYWORD(name) \
76 namespace tag \
77 { \
78 struct name; \
79 } \
80 template <typename T> \
81 struct name : ::boost::parameter::template_keyword<tag::name,T> \
82 { \
83 };
84/**/
85
86#endif // include guard
87
88

source code of include/boost/parameter/template_keyword.hpp