File indexing completed on 2025-01-30 09:59:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_RANGE_DEFINE_ADAPTOR_HPP_INCLUDED
0012 #define BOOST_RANGE_DEFINE_ADAPTOR_HPP_INCLUDED
0013
0014 #include <boost/tuple/tuple.hpp>
0015
0016 #define BOOST_DEFINE_RANGE_ADAPTOR( adaptor_name, range_adaptor ) \
0017 struct adaptor_name##_forwarder {}; \
0018 \
0019 template<typename Range> range_adaptor <Range> \
0020 operator|(Range& rng, adaptor_name##_forwarder) \
0021 { \
0022 return range_adaptor <Range>( rng ); \
0023 } \
0024 \
0025 template<typename Range> range_adaptor <const Range> \
0026 operator|(const Range& rng, adaptor_name##_forwarder) \
0027 { \
0028 return range_adaptor <const Range>( rng ); \
0029 } \
0030 \
0031 static adaptor_name##_forwarder adaptor_name = adaptor_name##_forwarder(); \
0032 \
0033 template<typename Range> \
0034 range_adaptor <Range> \
0035 make_##adaptor_name(Range& rng) \
0036 { \
0037 return range_adaptor <Range>(rng); \
0038 } \
0039 \
0040 template<typename Range> \
0041 range_adaptor <const Range> \
0042 make_##adaptor_name(const Range& rng) \
0043 { \
0044 return range_adaptor <const Range>(rng); \
0045 }
0046
0047 #define BOOST_DEFINE_RANGE_ADAPTOR_1( adaptor_name, range_adaptor, arg1_type ) \
0048 struct adaptor_name \
0049 { \
0050 explicit adaptor_name (arg1_type arg1_) \
0051 : arg1(arg1_) {} \
0052 arg1_type arg1; \
0053 }; \
0054 \
0055 template<typename Range> range_adaptor <Range> \
0056 operator|(Range& rng, adaptor_name args) \
0057 { \
0058 return range_adaptor <Range>(rng, args.arg1); \
0059 } \
0060 \
0061 template<typename Range> range_adaptor <const Range> \
0062 operator|(const Range& rng, adaptor_name args) \
0063 { \
0064 return range_adaptor <const Range>(rng, args.arg1); \
0065 } \
0066 \
0067 template<typename Range> \
0068 range_adaptor <Range> \
0069 make_##adaptor_name(Range& rng, arg1_type arg1) \
0070 { \
0071 return range_adaptor <Range>(rng, arg1); \
0072 } \
0073 \
0074 template<typename Range> \
0075 range_adaptor <const Range> \
0076 make_##adaptor_name(const Range& rng, arg1_type arg1) \
0077 { \
0078 return range_adaptor <const Range>(rng, arg1); \
0079 }
0080
0081 #define BOOST_RANGE_ADAPTOR_2( adaptor_name, range_adaptor, arg1_type, arg2_type ) \
0082 struct adaptor_name \
0083 { \
0084 explicit adaptor_name (arg1_type arg1_, arg2_type arg2_) \
0085 : arg1(arg1_), arg2(arg2_) {} \
0086 arg1_type arg1; \
0087 arg2_type arg2; \
0088 }; \
0089 \
0090 template<typename Range> range_adaptor <Range> \
0091 operator|(Range& rng, adaptor_name args) \
0092 { \
0093 return range_adaptor <Range>(rng, args.arg1, args.arg2); \
0094 } \
0095 template<typename Range> \
0096 range_adaptor <Range> \
0097 make_##adaptor_name(Range& rng, arg1_type arg1, arg2_type arg2) \
0098 { \
0099 return range_adaptor <Range>(rng, arg1, arg2); \
0100 } \
0101 template<typename Range> \
0102 range_adaptor <const Range> \
0103 make_##adaptor_name(const Range& rng, arg1_type arg1, arg2_type arg2) \
0104 { \
0105 return range_adaptor <const Range>(rng, arg1, arg2); \
0106 }
0107
0108
0109 #endif