File indexing completed on 2025-01-30 09:59:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_RANGE_ALGORITHM_TRANSFORM_HPP_INCLUDED
0010 #define BOOST_RANGE_ALGORITHM_TRANSFORM_HPP_INCLUDED
0011
0012 #include <boost/assert.hpp>
0013 #include <boost/concept_check.hpp>
0014 #include <boost/range/begin.hpp>
0015 #include <boost/range/end.hpp>
0016 #include <boost/range/concepts.hpp>
0017 #include <algorithm>
0018
0019 namespace boost
0020 {
0021 namespace range
0022 {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 template< class SinglePassRange1,
0034 class OutputIterator,
0035 class UnaryOperation >
0036 inline OutputIterator
0037 transform(const SinglePassRange1& rng,
0038 OutputIterator out,
0039 UnaryOperation fun)
0040 {
0041 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0042 return std::transform(boost::begin(rng),boost::end(rng),out,fun);
0043 }
0044
0045 }
0046
0047 namespace range_detail
0048 {
0049 template< class SinglePassTraversalReadableIterator1,
0050 class SinglePassTraversalReadableIterator2,
0051 class OutputIterator,
0052 class BinaryFunction >
0053 inline OutputIterator
0054 transform_impl(SinglePassTraversalReadableIterator1 first1,
0055 SinglePassTraversalReadableIterator1 last1,
0056 SinglePassTraversalReadableIterator2 first2,
0057 SinglePassTraversalReadableIterator2 last2,
0058 OutputIterator out,
0059 BinaryFunction fn)
0060 {
0061 for (; first1 != last1 && first2 != last2; ++first1, ++first2)
0062 {
0063 *out = fn(*first1, *first2);
0064 ++out;
0065 }
0066 return out;
0067 }
0068 }
0069
0070 namespace range
0071 {
0072
0073
0074 template< class SinglePassRange1,
0075 class SinglePassRange2,
0076 class OutputIterator,
0077 class BinaryOperation >
0078 inline OutputIterator
0079 transform(const SinglePassRange1& rng1,
0080 const SinglePassRange2& rng2,
0081 OutputIterator out,
0082 BinaryOperation fun)
0083 {
0084 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0085 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0086 return boost::range_detail::transform_impl(
0087 boost::begin(rng1), boost::end(rng1),
0088 boost::begin(rng2), boost::end(rng2),
0089 out, fun);
0090 }
0091
0092 }
0093 using range::transform;
0094 }
0095
0096 #endif