]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/include/boost/log/detail/parameter_tools.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / log / include / boost / log / detail / parameter_tools.hpp
1 /*
2 * Copyright Andrey Semashev 2007 - 2015.
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 /*!
8 * \file parameter_tools.hpp
9 * \author Andrey Semashev
10 * \date 28.06.2009
11 *
12 * \brief This header is the Boost.Log library implementation, see the library documentation
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
14 */
15
16 #ifndef BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
17 #define BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
18
19 #include <boost/parameter/keyword.hpp>
20 #include <boost/preprocessor/control/if.hpp>
21 #include <boost/preprocessor/comparison/equal.hpp>
22 #include <boost/preprocessor/repetition/enum_params.hpp>
23 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
24 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
25 #include <boost/preprocessor/facilities/intercept.hpp>
26 #include <boost/preprocessor/arithmetic/dec.hpp>
27 #include <boost/preprocessor/tuple/elem.hpp>
28 #include <boost/log/detail/config.hpp>
29 #include <boost/log/detail/sfinae_tools.hpp>
30 #include <boost/log/detail/header.hpp>
31
32 #ifdef BOOST_HAS_PRAGMA_ONCE
33 #pragma once
34 #endif
35
36 #ifndef BOOST_LOG_MAX_PARAMETER_ARGS
37 //! The maximum number of named arguments that are accepted by constructors and functions
38 #define BOOST_LOG_MAX_PARAMETER_ARGS 16
39 #endif
40
41 // The macro applies the passed macro with the specified arguments BOOST_LOG_MAX_PARAMETER_ARGS times
42 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(macro, args)\
43 public:\
44 BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, macro, args)
45
46 #define BOOST_LOG_CTOR_FORWARD_1(n, types)\
47 template< typename T0 >\
48 explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(T0 const& arg0, typename boost::log::aux::enable_if_named_parameters< T0, boost::log::aux::sfinae_dummy >::type = boost::log::aux::sfinae_dummy()) :\
49 BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))) {}
50
51 #define BOOST_LOG_CTOR_FORWARD_N(n, types)\
52 template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
53 explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg)) :\
54 BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))) {}
55
56 #define BOOST_LOG_CTOR_FORWARD(z, n, types)\
57 BOOST_PP_IF(BOOST_PP_EQUAL(n, 1), BOOST_LOG_CTOR_FORWARD_1, BOOST_LOG_CTOR_FORWARD_N)(n, types)
58
59 // The macro expands to a number of templated constructors that aggregate their named arguments
60 // into an ArgumentsPack and pass it to the base class constructor.
61 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_FORWARD(class_type, base_type)\
62 BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_FORWARD, (class_type, base_type))
63
64 #define BOOST_LOG_CTOR_CALL_1(n, types)\
65 template< typename T0 >\
66 explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(T0 const& arg0, typename boost::log::aux::enable_if_named_parameters< T0, boost::log::aux::sfinae_dummy >::type = boost::log::aux::sfinae_dummy())\
67 { BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))); }
68
69 #define BOOST_LOG_CTOR_CALL_N(n, types)\
70 template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
71 explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg))\
72 { BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))); }
73
74 #define BOOST_LOG_CTOR_CALL(z, n, types)\
75 BOOST_PP_IF(BOOST_PP_EQUAL(n, 1), BOOST_LOG_CTOR_CALL_1, BOOST_LOG_CTOR_CALL_N)(n, types)
76
77 // The macro expands to a number of templated constructors that aggregate their named arguments
78 // into an ArgumentsPack and pass it to a function call.
79 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(class_type, fun)\
80 BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_CALL, (class_type, fun))
81
82 namespace boost {
83
84 BOOST_LOG_OPEN_NAMESPACE
85
86 namespace aux {
87
88 // Yeah, not too cute. The empty_arg_list class should really be public.
89 // https://svn.boost.org/trac/boost/ticket/7247
90 typedef boost::parameter::aux::empty_arg_list empty_arg_list;
91
92 #if !(defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION))
93
94 //! The metafunction generates argument pack
95 template< typename ArgT0, typename... ArgsT >
96 struct make_arg_list
97 {
98 typedef boost::parameter::aux::arg_list< ArgT0, typename make_arg_list< ArgsT... >::type > type;
99 };
100
101 template< typename ArgT0 >
102 struct make_arg_list< ArgT0 >
103 {
104 typedef boost::parameter::aux::arg_list< ArgT0 > type;
105 };
106
107 #else
108
109 //! The metafunction generates argument pack
110 template< typename ArgT0, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), typename T, = void BOOST_PP_INTERCEPT) >
111 struct make_arg_list
112 {
113 typedef boost::parameter::aux::arg_list< ArgT0, typename make_arg_list< BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), T) >::type > type;
114 };
115
116 template< typename ArgT0 >
117 struct make_arg_list< ArgT0, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), void BOOST_PP_INTERCEPT) >
118 {
119 typedef boost::parameter::aux::arg_list< ArgT0 > type;
120 };
121
122 #endif
123
124 template< typename T, typename R >
125 struct enable_if_named_parameters {};
126
127 template< typename R >
128 struct enable_if_named_parameters< empty_arg_list, R >
129 {
130 typedef R type;
131 };
132
133 template< typename Keyword, typename Arg, typename R >
134 struct enable_if_named_parameters< boost::parameter::aux::tagged_argument< Keyword, Arg >, R >
135 {
136 typedef R type;
137 };
138
139 template< typename TaggedArg, typename Next, typename R >
140 struct enable_if_named_parameters< boost::parameter::aux::arg_list< TaggedArg, Next >, R >
141 {
142 typedef R type;
143 };
144
145 } // namespace aux
146
147 BOOST_LOG_CLOSE_NAMESPACE // namespace log
148
149 } // namespace boost
150
151 #include <boost/log/detail/footer.hpp>
152
153 #endif // BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_