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 value_ref_visitation.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 28.07.2012 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. In this file Chris@16: * internal configuration macros are defined. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_DETAIL_VALUE_REF_VISITATION_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_DETAIL_VALUE_REF_VISITATION_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: #include Chris@16: #include Chris@16: Chris@16: #ifndef BOOST_LOG_VALUE_REF_VISITATION_UNROLL_COUNT Chris@16: #define BOOST_LOG_VALUE_REF_VISITATION_UNROLL_COUNT 8 Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace aux { Chris@16: Chris@16: template< typename SequenceT, typename VisitorT, unsigned int SizeV = mpl::size< SequenceT >::value > Chris@16: struct apply_visitor_dispatch Chris@16: { Chris@16: typedef typename VisitorT::result_type result_type; Chris@16: Chris@16: static BOOST_FORCEINLINE result_type call(const void* p, unsigned int type_index, VisitorT& visitor) Chris@16: { Chris@16: typedef typename mpl::begin< SequenceT >::type begin_type; Chris@16: typedef typename mpl::advance_c< begin_type, SizeV / 2u >::type middle_type; Chris@16: if (type_index < (SizeV / 2u)) Chris@16: { Chris@16: typedef typename mpl::erase< SequenceT, middle_type, typename mpl::end< SequenceT >::type >::type new_sequence; Chris@16: typedef apply_visitor_dispatch< new_sequence, VisitorT > new_dispatch; Chris@16: return new_dispatch::call(p, type_index, visitor); Chris@16: } Chris@16: else Chris@16: { Chris@16: typedef typename mpl::erase< SequenceT, begin_type, middle_type >::type new_sequence; Chris@16: typedef apply_visitor_dispatch< new_sequence, VisitorT > new_dispatch; Chris@16: return new_dispatch::call(p, type_index - (SizeV / 2u), visitor); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: #define BOOST_LOG_AUX_CASE_ENTRY(z, i, data)\ Chris@16: case i: return visitor(*static_cast< typename mpl::at_c< SequenceT, i >::type const* >(p)); Chris@16: Chris@16: #define BOOST_PP_FILENAME_1 Chris@16: #define BOOST_PP_ITERATION_LIMITS (1, BOOST_PP_INC(BOOST_LOG_VALUE_REF_VISITATION_VTABLE_SIZE)) Chris@16: #include BOOST_PP_ITERATE() Chris@16: Chris@16: #undef BOOST_LOG_AUX_CASE_ENTRY 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_VALUE_REF_VISITATION_HPP_INCLUDED_ Chris@16: Chris@16: #ifdef BOOST_PP_IS_ITERATING Chris@16: Chris@16: #define BOOST_LOG_AUX_SWITCH_SIZE BOOST_PP_ITERATION() Chris@16: Chris@16: template< typename SequenceT, typename VisitorT > Chris@16: struct apply_visitor_dispatch< SequenceT, VisitorT, BOOST_LOG_AUX_SWITCH_SIZE > Chris@16: { Chris@16: typedef typename VisitorT::result_type result_type; Chris@16: Chris@16: static BOOST_FORCEINLINE result_type call(const void* p, unsigned int type_index, VisitorT& visitor) Chris@16: { Chris@16: switch (type_index) Chris@16: { Chris@16: BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_AUX_SWITCH_SIZE, BOOST_LOG_AUX_CASE_ENTRY, ~) Chris@16: default: Chris@16: return visitor(*static_cast< typename mpl::at_c< SequenceT, 0 >::type const* >(p)); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: #undef BOOST_LOG_AUX_SWITCH_SIZE Chris@16: Chris@16: #endif // BOOST_PP_IS_ITERATING