Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file parameter_tools.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 28.06.2009 Chris@16: * Chris@16: * \brief This header is the Boost.Log library implementation, see the library documentation Chris@16: * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #ifndef BOOST_LOG_MAX_PARAMETER_ARGS Chris@16: //! The maximum number of named arguments that are accepted by constructors and functions Chris@16: #define BOOST_LOG_MAX_PARAMETER_ARGS 16 Chris@16: #endif Chris@16: Chris@16: // The macro applies the passed macro with the specified arguments BOOST_LOG_MAX_PARAMETER_ARGS times Chris@16: #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(macro, args)\ Chris@16: public:\ Chris@16: BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, macro, args) Chris@16: Chris@16: Chris@16: #define BOOST_LOG_CTOR_FORWARD(z, n, types)\ Chris@16: template< BOOST_PP_ENUM_PARAMS(n, typename T) >\ Chris@16: explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg)) :\ Chris@16: BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))) {} Chris@16: Chris@16: // The macro expands to a number of templated constructors that aggregate their named arguments Chris@16: // into an ArgumentsPack and pass it to the base class constructor. Chris@16: #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_FORWARD(class_type, base_type)\ Chris@16: BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_FORWARD, (class_type, base_type)) Chris@16: Chris@16: Chris@16: #define BOOST_LOG_CTOR_CALL(z, n, types)\ Chris@16: template< BOOST_PP_ENUM_PARAMS(n, typename T) >\ Chris@16: explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg))\ Chris@16: { BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))); } Chris@16: Chris@16: // The macro expands to a number of templated constructors that aggregate their named arguments Chris@16: // into an ArgumentsPack and pass it to a function call. Chris@16: #define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(class_type, fun)\ Chris@16: BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_CALL, (class_type, fun)) Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace aux { Chris@16: Chris@16: // Yeah, not too cute. The empty_arg_list class should really be public. Chris@16: typedef boost::parameter::aux::empty_arg_list empty_arg_list; Chris@16: Chris@16: #if !(defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION)) Chris@16: Chris@16: //! The metafunction generates argument pack Chris@16: template< typename ArgT0, typename... ArgsT > Chris@16: struct make_arg_list Chris@16: { Chris@16: typedef boost::parameter::aux::arg_list< ArgT0, typename make_arg_list< ArgsT... >::type > type; Chris@16: }; Chris@16: Chris@16: template< typename ArgT0 > Chris@16: struct make_arg_list< ArgT0 > Chris@16: { Chris@16: typedef boost::parameter::aux::arg_list< ArgT0 > type; Chris@16: }; Chris@16: Chris@16: #else Chris@16: Chris@16: //! The metafunction generates argument pack Chris@16: template< typename ArgT0, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), typename T, = void BOOST_PP_INTERCEPT) > Chris@16: struct make_arg_list Chris@16: { Chris@16: 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; Chris@16: }; Chris@16: Chris@16: template< typename ArgT0 > Chris@16: struct make_arg_list< ArgT0, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PARAMETER_ARGS), void BOOST_PP_INTERCEPT) > Chris@16: { Chris@16: typedef boost::parameter::aux::arg_list< ArgT0 > type; Chris@16: }; Chris@16: Chris@16: #endif Chris@16: Chris@16: } // namespace aux Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_