comparison DEPENDENCIES/generic/include/boost/log/detail/parameter_tools.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 /*
2 * Copyright Andrey Semashev 2007 - 2013.
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/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>
28
29 #ifdef BOOST_HAS_PRAGMA_ONCE
30 #pragma once
31 #endif
32
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
36 #endif
37
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)\
40 public:\
41 BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, macro, args)
42
43
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))) {}
48
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))
53
54
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))); }
59
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))
64
65 namespace boost {
66
67 BOOST_LOG_OPEN_NAMESPACE
68
69 namespace aux {
70
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;
73
74 #if !(defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION))
75
76 //! The metafunction generates argument pack
77 template< typename ArgT0, typename... ArgsT >
78 struct make_arg_list
79 {
80 typedef boost::parameter::aux::arg_list< ArgT0, typename make_arg_list< ArgsT... >::type > type;
81 };
82
83 template< typename ArgT0 >
84 struct make_arg_list< ArgT0 >
85 {
86 typedef boost::parameter::aux::arg_list< ArgT0 > type;
87 };
88
89 #else
90
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) >
93 struct make_arg_list
94 {
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;
96 };
97
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) >
100 {
101 typedef boost::parameter::aux::arg_list< ArgT0 > type;
102 };
103
104 #endif
105
106 } // namespace aux
107
108 BOOST_LOG_CLOSE_NAMESPACE // namespace log
109
110 } // namespace boost
111
112 #include <boost/log/detail/footer.hpp>
113
114 #endif // BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_