Work around Boost.Parameter difference between develop and master for file_name.

This commit reworks file_name parameter handling for the file sink setup helper.
Boost.Parameter was modified recently in develop, which made it incompatible
with the previous implementation of the file_name helpers. At the same time,
it has not been merged to master, and the master version is not compatible
with the new implementation.

To resolve this, avoid mentioning the actual type of the tagged argument
constructed from the assignment to the named parameter keyword. This type refers
to Boost.Parameter implementation details namespace, so as a bonus we reduce
the dependency on Boost.Parameter implementation details.

See: https://github.com/boostorg/parameter/issues/65
This commit is contained in:
Andrey Semashev 2019-01-16 23:57:25 +03:00
parent 4110bfdd1e
commit 2dd530b8c3

View File

@ -15,9 +15,11 @@
#ifndef BOOST_LOG_UTILITY_SETUP_FILE_HPP_INCLUDED_
#define BOOST_LOG_UTILITY_SETUP_FILE_HPP_INCLUDED_
#include <boost/type_traits/is_void.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared_object.hpp>
#include <boost/parameter/parameters.hpp> // for is_named_argument
#include <boost/preprocessor/control/expr_if.hpp>
#include <boost/preprocessor/comparison/greater.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
@ -96,18 +98,36 @@ shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL< sinks::text_file_backend > >
return pSink;
}
//! The function wraps the argument into a file_name named argument, if needed
template< typename T >
inline T const& wrap_file_name(T const& arg, mpl::true_)
//! The trait wraps the argument into a file_name named argument, if needed
template< typename T, bool IsNamedArgument = parameter::aux::is_named_argument< T >::value >
struct file_name_param_traits
{
return arg;
}
static shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL< sinks::text_file_backend > > wrap_add_file_log(T const& file_name_arg)
{
return aux::add_file_log(file_name_arg);
}
template< typename ArgsT >
static shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL< sinks::text_file_backend > > wrap_add_file_log(T const& file_name_arg, ArgsT const& args)
{
return aux::add_file_log((args, file_name_arg));
}
};
template< typename T >
inline typename parameter::aux::tag< keywords::tag::file_name, T const& >::type
wrap_file_name(T const& arg, mpl::false_)
struct file_name_param_traits< T, false >
{
return keywords::file_name = arg;
}
static shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL< sinks::text_file_backend > > wrap_add_file_log(T const& file_name_arg)
{
return aux::add_file_log(keywords::file_name = file_name_arg);
}
template< typename ArgsT >
static shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL< sinks::text_file_backend > > wrap_add_file_log(T const& file_name_arg, ArgsT const& args)
{
return aux::add_file_log((args, (keywords::file_name = file_name_arg)));
}
};
} // namespace aux
@ -117,11 +137,11 @@ wrap_file_name(T const& arg, mpl::false_)
template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
inline shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL< sinks::text_file_backend > > add_file_log(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg))\
{\
return aux::add_file_log((\
aux::wrap_file_name(arg0, typename parameter::aux::is_named_argument< T0 >::type())\
return aux::file_name_param_traits< T0 >::wrap_add_file_log(\
arg0\
BOOST_PP_COMMA_IF(BOOST_PP_GREATER(n, 1))\
BOOST_PP_ENUM_SHIFTED_PARAMS(n, arg)\
));\
BOOST_PP_EXPR_IF(BOOST_PP_GREATER(n, 1), (BOOST_PP_ENUM_SHIFTED_PARAMS(n, arg)))\
);\
}
BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, BOOST_LOG_INIT_LOG_TO_FILE_INTERNAL, ~)