File indexing completed on 2025-12-15 09:57:31
0001
0002 #ifndef BOOST_MPL_TRANSFORM_HPP_INCLUDED
0003 #define BOOST_MPL_TRANSFORM_HPP_INCLUDED
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <boost/mpl/fold.hpp>
0019 #include <boost/mpl/reverse_fold.hpp>
0020 #include <boost/mpl/pair_view.hpp>
0021 #include <boost/mpl/is_sequence.hpp>
0022 #include <boost/mpl/eval_if.hpp>
0023 #include <boost/mpl/lambda.hpp>
0024 #include <boost/mpl/bind.hpp>
0025 #include <boost/mpl/or.hpp>
0026 #include <boost/mpl/not.hpp>
0027 #include <boost/mpl/aux_/na.hpp>
0028 #include <boost/mpl/aux_/inserter_algorithm.hpp>
0029
0030 namespace boost { namespace mpl {
0031
0032 namespace aux {
0033
0034 template<
0035 typename Seq
0036 , typename Op
0037 , typename In
0038 >
0039 struct transform1_impl
0040 : fold<
0041 Seq
0042 , typename In::state
0043 , bind2< typename lambda< typename In::operation >::type
0044 , _1
0045 , bind1< typename lambda<Op>::type, _2>
0046 >
0047 >
0048 {
0049 };
0050
0051 template<
0052 typename Seq
0053 , typename Op
0054 , typename In
0055 >
0056 struct reverse_transform1_impl
0057 : reverse_fold<
0058 Seq
0059 , typename In::state
0060 , bind2< typename lambda< typename In::operation >::type
0061 , _1
0062 , bind1< typename lambda<Op>::type, _2>
0063 >
0064 >
0065 {
0066 };
0067
0068 template<
0069 typename Seq1
0070 , typename Seq2
0071 , typename Op
0072 , typename In
0073 >
0074 struct transform2_impl
0075 : fold<
0076 pair_view<Seq1,Seq2>
0077 , typename In::state
0078 , bind2< typename lambda< typename In::operation >::type
0079 , _1
0080 , bind2<
0081 typename lambda<Op>::type
0082 , bind1<first<>,_2>
0083 , bind1<second<>,_2>
0084 >
0085 >
0086 >
0087 {
0088 };
0089
0090 template<
0091 typename Seq1
0092 , typename Seq2
0093 , typename Op
0094 , typename In
0095 >
0096 struct reverse_transform2_impl
0097 : reverse_fold<
0098 pair_view<Seq1,Seq2>
0099 , typename In::state
0100 , bind2< typename lambda< typename In::operation >::type
0101 , _1
0102 , bind2< typename lambda< Op >::type
0103 , bind1<first<>,_2>
0104 , bind1<second<>,_2>
0105 >
0106 >
0107 >
0108 {
0109 };
0110
0111 }
0112
0113 BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(3, transform1)
0114 BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(4, transform2)
0115
0116 #define AUX778076_TRANSFORM_DEF(name) \
0117 template< \
0118 typename BOOST_MPL_AUX_NA_PARAM(Seq1) \
0119 , typename BOOST_MPL_AUX_NA_PARAM(Seq2OrOperation) \
0120 , typename BOOST_MPL_AUX_NA_PARAM(OperationOrInserter) \
0121 , typename BOOST_MPL_AUX_NA_PARAM(Inserter) \
0122 > \
0123 struct name \
0124 { \
0125 typedef typename eval_if< \
0126 or_< \
0127 is_na<OperationOrInserter> \
0128 , is_lambda_expression< Seq2OrOperation > \
0129 , not_< is_sequence<Seq2OrOperation> > \
0130 > \
0131 , name##1<Seq1,Seq2OrOperation,OperationOrInserter> \
0132 , name##2<Seq1,Seq2OrOperation,OperationOrInserter,Inserter> \
0133 >::type type; \
0134 }; \
0135 BOOST_MPL_AUX_NA_SPEC(4, name) \
0136
0137
0138 AUX778076_TRANSFORM_DEF(transform)
0139 AUX778076_TRANSFORM_DEF(reverse_transform)
0140
0141 #undef AUX778076_TRANSFORM_DEF
0142
0143 }}
0144
0145 #endif