mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-30 20:47:31 +02:00
reduce number of template instantiations
[SVN r53566]
This commit is contained in:
@ -28,13 +28,7 @@ namespace boost { namespace fusion
|
|||||||
struct apply
|
struct apply
|
||||||
{
|
{
|
||||||
typedef mpl::at<typename Sequence::types, N> element;
|
typedef mpl::at<typename Sequence::types, N> element;
|
||||||
typedef typename
|
typedef typename detail::ref_result<element>::type type;
|
||||||
mpl::eval_if<
|
|
||||||
is_const<Sequence>
|
|
||||||
, detail::cref_result<element>
|
|
||||||
, detail::ref_result<element>
|
|
||||||
>::type
|
|
||||||
type;
|
|
||||||
|
|
||||||
static type
|
static type
|
||||||
call(Sequence& v)
|
call(Sequence& v)
|
||||||
@ -42,6 +36,19 @@ namespace boost { namespace fusion
|
|||||||
return v.at_impl(N());
|
return v.at_impl(N());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Sequence, typename N>
|
||||||
|
struct apply <Sequence const, N>
|
||||||
|
{
|
||||||
|
typedef mpl::at<typename Sequence::types, N> element;
|
||||||
|
typedef typename detail::cref_result<element>::type type;
|
||||||
|
|
||||||
|
static type
|
||||||
|
call(Sequence const& v)
|
||||||
|
{
|
||||||
|
return v.at_impl(N());
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -25,11 +25,12 @@
|
|||||||
#include <boost/fusion/container/vector/vector50.hpp>
|
#include <boost/fusion/container/vector/vector50.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/mpl/distance.hpp>
|
|
||||||
#include <boost/mpl/find.hpp>
|
|
||||||
#include <boost/mpl/begin_end.hpp>
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
#include <boost/preprocessor/arithmetic/dec.hpp>
|
||||||
|
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||||
|
#include <boost/preprocessor/facilities/intercept.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
|
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
@ -38,40 +39,23 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
namespace boost { namespace fusion { namespace detail
|
namespace boost { namespace fusion { namespace detail
|
||||||
{
|
{
|
||||||
template <int N>
|
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
|
||||||
struct get_vector_n;
|
struct vector_n_chooser
|
||||||
|
{
|
||||||
|
typedef BOOST_PP_CAT(vector, FUSION_MAX_VECTOR_SIZE)<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)> type;
|
||||||
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct get_vector_n<0>
|
struct vector_n_chooser<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, void_ BOOST_PP_INTERCEPT)>
|
||||||
{
|
|
||||||
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
|
|
||||||
struct call
|
|
||||||
{
|
{
|
||||||
typedef vector0 type;
|
typedef vector0 type;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
#define BOOST_PP_FILENAME_1 \
|
#define BOOST_PP_FILENAME_1 \
|
||||||
<boost/fusion/container/vector/detail/vector_n_chooser.hpp>
|
<boost/fusion/container/vector/detail/vector_n_chooser.hpp>
|
||||||
#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE)
|
#define BOOST_PP_ITERATION_LIMITS (1, BOOST_PP_DEC(FUSION_MAX_VECTOR_SIZE))
|
||||||
#include BOOST_PP_ITERATE()
|
#include BOOST_PP_ITERATE()
|
||||||
|
|
||||||
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
|
|
||||||
struct vector_n_chooser
|
|
||||||
{
|
|
||||||
typedef
|
|
||||||
mpl::BOOST_PP_CAT(vector, FUSION_MAX_VECTOR_SIZE)
|
|
||||||
<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)>
|
|
||||||
input;
|
|
||||||
|
|
||||||
typedef typename mpl::begin<input>::type begin;
|
|
||||||
typedef typename mpl::find<input, void_>::type end;
|
|
||||||
typedef typename mpl::distance<begin, end>::type size;
|
|
||||||
|
|
||||||
typedef typename get_vector_n<size::value>::template
|
|
||||||
call<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)>::type
|
|
||||||
type;
|
|
||||||
};
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -85,15 +69,13 @@ namespace boost { namespace fusion { namespace detail
|
|||||||
|
|
||||||
#define N BOOST_PP_ITERATION()
|
#define N BOOST_PP_ITERATION()
|
||||||
|
|
||||||
template <>
|
template <BOOST_PP_ENUM_PARAMS(N, typename T)>
|
||||||
struct get_vector_n<N>
|
struct vector_n_chooser<
|
||||||
{
|
BOOST_PP_ENUM_PARAMS(N, T)
|
||||||
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
|
BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(FUSION_MAX_VECTOR_SIZE, N), void_ BOOST_PP_INTERCEPT)>
|
||||||
struct call
|
|
||||||
{
|
{
|
||||||
typedef BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> type;
|
typedef BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> type;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
#undef N
|
#undef N
|
||||||
#endif // defined(BOOST_PP_IS_ITERATING)
|
#endif // defined(BOOST_PP_IS_ITERATING)
|
||||||
|
@ -7,12 +7,8 @@
|
|||||||
#if !defined(FUSION_ACCESS_04182005_0737)
|
#if !defined(FUSION_ACCESS_04182005_0737)
|
||||||
#define FUSION_ACCESS_04182005_0737
|
#define FUSION_ACCESS_04182005_0737
|
||||||
|
|
||||||
#include <boost/mpl/eval_if.hpp>
|
|
||||||
#include <boost/mpl/identity.hpp>
|
|
||||||
#include <boost/type_traits/add_const.hpp>
|
#include <boost/type_traits/add_const.hpp>
|
||||||
#include <boost/type_traits/add_reference.hpp>
|
#include <boost/type_traits/add_reference.hpp>
|
||||||
#include <boost/type_traits/is_reference.hpp>
|
|
||||||
#include <boost/type_traits/remove_cv.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion { namespace detail
|
namespace boost { namespace fusion { namespace detail
|
||||||
{
|
{
|
||||||
@ -33,22 +29,35 @@ namespace boost { namespace fusion { namespace detail
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct non_ref_parameter
|
struct call_param
|
||||||
{
|
{
|
||||||
typedef typename boost::remove_cv<T>::type const& type;
|
typedef T const& type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct call_param
|
struct call_param<T &>
|
||||||
{
|
{
|
||||||
typedef typename
|
typedef T& type;
|
||||||
mpl::eval_if<
|
|
||||||
is_reference<T>
|
|
||||||
, mpl::identity<T>
|
|
||||||
, non_ref_parameter<T>
|
|
||||||
>::type
|
|
||||||
type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct call_param<T const>
|
||||||
|
{
|
||||||
|
typedef T const& type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct call_param<T volatile>
|
||||||
|
{
|
||||||
|
typedef T const& type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct call_param<T const volatile>
|
||||||
|
{
|
||||||
|
typedef T const& type;
|
||||||
|
};
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user