2 * Copyright Andrey Semashev 2007 - 2014.
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)
8 * \file parameter_tools.hpp
9 * \author Andrey Semashev
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.
16 #ifndef BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
17 #define BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
19 #include <boost/parameter/keyword.hpp>
20 #include <boost/preprocessor/repetition/enum_params.hpp>
21 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
22 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
23 #include <boost/preprocessor/facilities/intercept.hpp>
24 #include <boost/preprocessor/arithmetic/dec.hpp>
25 #include <boost/preprocessor/tuple/elem.hpp>
26 #include <boost/log/detail/config.hpp>
27 #include <boost/log/detail/header.hpp>
29 #ifdef BOOST_HAS_PRAGMA_ONCE
33 #ifndef BOOST_LOG_MAX_PARAMETER_ARGS
34 //! The maximum number of named arguments that are accepted by constructors and functions
35 #define BOOST_LOG_MAX_PARAMETER_ARGS 16
38 // The macro applies the passed macro with the specified arguments BOOST_LOG_MAX_PARAMETER_ARGS times
39 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(macro, args)\
41 BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, macro, args)
44 #define BOOST_LOG_CTOR_FORWARD(z, n, types)\
45 template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
46 explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg)) :\
47 BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))) {}
49 // The macro expands to a number of templated constructors that aggregate their named arguments
50 // into an ArgumentsPack and pass it to the base class constructor.
51 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_FORWARD(class_type, base_type)\
52 BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_FORWARD, (class_type, base_type))
55 #define BOOST_LOG_CTOR_CALL(z, n, types)\
56 template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
57 explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg))\
58 { BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))); }
60 // The macro expands to a number of templated constructors that aggregate their named arguments
61 // into an ArgumentsPack and pass it to a function call.
62 #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(class_type, fun)\
63 BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_CALL, (class_type, fun))
67 BOOST_LOG_OPEN_NAMESPACE
71 // Yeah, not too cute. The empty_arg_list class should really be public.
72 typedef boost::parameter::aux::empty_arg_list empty_arg_list;
74 #if !(defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION))
76 //! The metafunction generates argument pack
77 template< typename ArgT0, typename... ArgsT >
80 typedef boost::parameter::aux::arg_list< ArgT0, typename make_arg_list< ArgsT... >::type > type;
83 template< typename ArgT0 >
84 struct make_arg_list< ArgT0 >
86 typedef boost::parameter::aux::arg_list< ArgT0 > type;
91 //! The metafunction generates argument pack
92 template< typename ArgT0, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), typename T, = void BOOST_PP_INTERCEPT) >
95 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;
98 template< typename ArgT0 >
99 struct make_arg_list< ArgT0, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), void BOOST_PP_INTERCEPT) >
101 typedef boost::parameter::aux::arg_list< ArgT0 > type;
108 BOOST_LOG_CLOSE_NAMESPACE // namespace log
112 #include <boost/log/detail/footer.hpp>
114 #endif // BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_