forked from boostorg/range
Merge branch 'develop'
This commit is contained in:
@ -41,20 +41,32 @@ namespace boost
|
||||
typedef F transform_fn_type;
|
||||
typedef R source_range_type;
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
transformed_range( F f, R& r )
|
||||
: base( boost::make_transform_iterator( boost::begin(r), f ),
|
||||
boost::make_transform_iterator( boost::end(r), f ) )
|
||||
|
||||
{ }
|
||||
{
|
||||
}
|
||||
#else
|
||||
transformed_range(F&& f, R&& r)
|
||||
: base(typename base::iterator(boost::begin(r), std::forward(f),
|
||||
typename base::iterator(boost::end(r), std::forward(f))))
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
template< class T >
|
||||
struct transform_holder : holder<T>
|
||||
{
|
||||
transform_holder( T r ) : holder<T>(r)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template< class InputRng, class UnaryFunction >
|
||||
inline transformed_range<UnaryFunction,InputRng>
|
||||
operator|( InputRng& r,
|
||||
@ -70,6 +82,16 @@ namespace boost
|
||||
{
|
||||
return transformed_range<UnaryFunction, const InputRng>( f.val, r );
|
||||
}
|
||||
#else
|
||||
template<class InputRng, class UnaryFunction>
|
||||
inline transformed_range<UnaryFunction,InputRng>
|
||||
operator|(InputRng&& r,
|
||||
transform_holder<UnaryFunction>&& f)
|
||||
{
|
||||
return transformed_range<UnaryFunction, InputRng>(
|
||||
f.val, std::forward(r));
|
||||
}
|
||||
#endif
|
||||
|
||||
} // 'range_detail'
|
||||
|
||||
@ -84,6 +106,7 @@ namespace boost
|
||||
range_detail::forwarder<range_detail::transform_holder>();
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template<class UnaryFunction, class InputRange>
|
||||
inline transformed_range<UnaryFunction, InputRange>
|
||||
transform(InputRange& rng, UnaryFunction fn)
|
||||
@ -97,6 +120,16 @@ namespace boost
|
||||
{
|
||||
return transformed_range<UnaryFunction, const InputRange>(fn, rng);
|
||||
}
|
||||
#else
|
||||
template<typename UnaryFunction, typename InputRange>
|
||||
inline transformed_range<UnaryFunction, InputRange>
|
||||
transform(InputRange&& rng, UnaryFunction&& fn)
|
||||
{
|
||||
return transformed_range<UnaryFunction, InputRange>(
|
||||
std::forward(fn), std::forward(rng));
|
||||
}
|
||||
|
||||
#endif
|
||||
} // 'adaptors'
|
||||
|
||||
}
|
||||
|
@ -285,8 +285,8 @@ namespace boost {
|
||||
iterator i1 = boost::begin(*m_range);
|
||||
iterator i2 = boost::end(*m_range);
|
||||
|
||||
ignore_unused_variable_warning(i1);
|
||||
ignore_unused_variable_warning(i2);
|
||||
boost::ignore_unused_variable_warning(i1);
|
||||
boost::ignore_unused_variable_warning(i2);
|
||||
|
||||
const_constraints(*m_range);
|
||||
}
|
||||
@ -297,8 +297,8 @@ namespace boost {
|
||||
const_iterator ci1 = boost::begin(const_range);
|
||||
const_iterator ci2 = boost::end(const_range);
|
||||
|
||||
ignore_unused_variable_warning(ci1);
|
||||
ignore_unused_variable_warning(ci2);
|
||||
boost::ignore_unused_variable_warning(ci1);
|
||||
boost::ignore_unused_variable_warning(ci2);
|
||||
}
|
||||
|
||||
// Rationale:
|
||||
|
@ -651,6 +651,13 @@ public:
|
||||
return iterator_range<IteratorT>( Begin, End );
|
||||
}
|
||||
|
||||
template<typename IteratorT, typename IntegerT>
|
||||
inline iterator_range<IteratorT>
|
||||
make_iterator_range_n(IteratorT first, IntegerT n)
|
||||
{
|
||||
return iterator_range<IteratorT>(first, boost::next(first, n));
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename Range >
|
||||
|
94
include/boost/range/separated.hpp
Normal file
94
include/boost/range/separated.hpp
Normal file
@ -0,0 +1,94 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2014.
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_SEPARATED_HPP_INCLUDED
|
||||
#define BOOST_RANGE_SEPARATED_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
|
||||
template<typename Iter, typename Separator>
|
||||
class output_stream_writer
|
||||
{
|
||||
public:
|
||||
output_stream_writer(Iter first, Iter last, Separator separator)
|
||||
: m_first(first)
|
||||
, m_last(last)
|
||||
, m_separator(separator)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename OStream>
|
||||
void write(OStream& out) const
|
||||
{
|
||||
write_impl(out, m_first, m_last, m_separator);
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename OStream>
|
||||
static void write_impl(
|
||||
OStream& out, Iter first, Iter last, Separator separator)
|
||||
{
|
||||
if (first != last)
|
||||
{
|
||||
out << *first;
|
||||
for (++first; first != last; ++first)
|
||||
{
|
||||
out << separator << *first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iter m_first;
|
||||
Iter m_last;
|
||||
Separator m_separator;
|
||||
};
|
||||
|
||||
template<typename Char, typename Traits, typename Iter, typename Separator>
|
||||
std::basic_ostream<Char, Traits>&
|
||||
operator<<(
|
||||
std::basic_ostream<Char, Traits>& out,
|
||||
const output_stream_writer<Iter, Separator>& writer)
|
||||
{
|
||||
writer.write(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace range_detail
|
||||
|
||||
namespace range
|
||||
{
|
||||
|
||||
template<typename Range, typename Separator>
|
||||
inline range_detail::output_stream_writer<
|
||||
typename range_iterator<const Range>::type,
|
||||
Separator
|
||||
>
|
||||
separated(const Range& rng, Separator separator)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const Range>));
|
||||
return range_detail::output_stream_writer<
|
||||
typename range_iterator<const Range>::type,
|
||||
Separator
|
||||
>(boost::begin(rng), boost::end(rng), separator);
|
||||
}
|
||||
|
||||
} // namespace range
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
Reference in New Issue
Block a user