forked from boostorg/range
Merge branch 'develop'
This commit is contained in:
@ -29,12 +29,18 @@ inline Container& insert( Container& on,
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
|
||||
BOOST_ASSERT( (void*)&on != (void*)&from &&
|
||||
"cannot copy from a container to itself" );
|
||||
on.insert( before, boost::begin(from), boost::end(from) );
|
||||
return on;
|
||||
}
|
||||
|
||||
template< class Container, class Range >
|
||||
inline Container& insert( Container& on, const Range& from )
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
|
||||
on.insert(boost::begin(from), boost::end(from));
|
||||
}
|
||||
|
||||
} // namespace range
|
||||
using range::insert;
|
||||
} // namespace boost
|
||||
|
@ -75,8 +75,8 @@ namespace boost
|
||||
template<
|
||||
class Value
|
||||
, class Traversal
|
||||
, class Reference
|
||||
, class Difference
|
||||
, class Reference = Value&
|
||||
, class Difference = std::ptrdiff_t
|
||||
, class Buffer = use_default
|
||||
>
|
||||
class any_range
|
||||
|
@ -9,296 +9,37 @@
|
||||
#ifndef BOOST_RANGE_COMBINE_HPP
|
||||
#define BOOST_RANGE_COMBINE_HPP
|
||||
|
||||
#include <boost/iterator/zip_iterator.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/type_traits/is_void.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/plus.hpp>
|
||||
#include <boost/mpl/arithmetic.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/iterator/zip_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
namespace range
|
||||
{
|
||||
|
||||
template<typename IterTuple>
|
||||
class combined_range
|
||||
: public iterator_range<zip_iterator<IterTuple> >
|
||||
{
|
||||
typedef iterator_range<zip_iterator<IterTuple> > base;
|
||||
public:
|
||||
combined_range(IterTuple first, IterTuple last)
|
||||
: base(first, last)
|
||||
{
|
||||
struct void_ { typedef void_ type; };
|
||||
}
|
||||
|
||||
template<> struct range_iterator< ::boost::range_detail::void_ >
|
||||
{
|
||||
typedef ::boost::tuples::null_type type;
|
||||
};
|
||||
|
||||
namespace range_detail
|
||||
{
|
||||
inline ::boost::tuples::null_type range_begin( ::boost::range_detail::void_& )
|
||||
{ return ::boost::tuples::null_type(); }
|
||||
|
||||
inline ::boost::tuples::null_type range_begin( const ::boost::range_detail::void_& )
|
||||
{ return ::boost::tuples::null_type(); }
|
||||
|
||||
inline ::boost::tuples::null_type range_end( ::boost::range_detail::void_& )
|
||||
{ return ::boost::tuples::null_type(); }
|
||||
|
||||
inline ::boost::tuples::null_type range_end( const ::boost::range_detail::void_& )
|
||||
{ return ::boost::tuples::null_type(); }
|
||||
|
||||
template< class T >
|
||||
struct tuple_iter
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::eval_if_c<
|
||||
::boost::is_same<T, ::boost::range_detail::void_ >::value,
|
||||
::boost::mpl::identity< ::boost::tuples::null_type >,
|
||||
::boost::range_iterator<T>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template< class Rng1, class Rng2 >
|
||||
struct tuple_range
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::eval_if_c<
|
||||
::boost::is_same<Rng1, ::boost::range_detail::void_ >::value,
|
||||
::boost::range_detail::void_,
|
||||
::boost::mpl::identity<Rng1>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
class R1,
|
||||
class R2,
|
||||
class R3,
|
||||
class R4,
|
||||
class R5,
|
||||
class R6
|
||||
>
|
||||
struct generate_tuple
|
||||
{
|
||||
typedef ::boost::tuples::tuple<
|
||||
BOOST_DEDUCED_TYPENAME tuple_iter<R1>::type,
|
||||
BOOST_DEDUCED_TYPENAME tuple_iter<R2>::type,
|
||||
BOOST_DEDUCED_TYPENAME tuple_iter<R3>::type,
|
||||
BOOST_DEDUCED_TYPENAME tuple_iter<R4>::type,
|
||||
BOOST_DEDUCED_TYPENAME tuple_iter<R5>::type,
|
||||
BOOST_DEDUCED_TYPENAME tuple_iter<R6>::type
|
||||
> type;
|
||||
|
||||
static type begin( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 )
|
||||
{
|
||||
return ::boost::tuples::make_tuple( ::boost::begin(r1),
|
||||
::boost::begin(r2),
|
||||
::boost::begin(r3),
|
||||
::boost::begin(r4),
|
||||
::boost::begin(r5),
|
||||
::boost::begin(r6) );
|
||||
}
|
||||
|
||||
static type end( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 )
|
||||
{
|
||||
return ::boost::tuples::make_tuple( ::boost::end(r1),
|
||||
::boost::end(r2),
|
||||
::boost::end(r3),
|
||||
::boost::end(r4),
|
||||
::boost::end(r5),
|
||||
::boost::end(r6) );
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
class R1,
|
||||
class R2 = void_,
|
||||
class R3 = void_,
|
||||
class R4 = void_,
|
||||
class R5 = void_,
|
||||
class R6 = void_
|
||||
>
|
||||
struct zip_rng
|
||||
: iterator_range<
|
||||
zip_iterator<
|
||||
BOOST_DEDUCED_TYPENAME generate_tuple<R1,R2,R3,R4,R5,R6>::type
|
||||
>
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef generate_tuple<R1,R2,R3,R4,R5,R6> generator_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME generator_t::type tuple_t;
|
||||
typedef zip_iterator<tuple_t> zip_iter_t;
|
||||
typedef iterator_range<zip_iter_t> base_t;
|
||||
|
||||
public:
|
||||
zip_rng( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 )
|
||||
: base_t( zip_iter_t( generator_t::begin(r1,r2,r3,r4,r5,r6) ),
|
||||
zip_iter_t( generator_t::end(r1,r2,r3,r4,r5,r6) ) )
|
||||
{
|
||||
BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r2));
|
||||
BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r3));
|
||||
BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r4));
|
||||
BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r5));
|
||||
BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r6));
|
||||
}
|
||||
|
||||
template< class Zip, class Rng >
|
||||
zip_rng( Zip& z, Rng& r )
|
||||
: base_t( zip_iter_t( generator_t::begin( z, r ) ),
|
||||
zip_iter_t( generator_t::end( z, r ) ) )
|
||||
{
|
||||
|
||||
// @todo: tuple::begin( should be overloaded for this situation
|
||||
}
|
||||
|
||||
struct tuple_length : ::boost::tuples::length<tuple_t>
|
||||
{ };
|
||||
|
||||
template< unsigned N >
|
||||
struct get
|
||||
{
|
||||
template< class Z, class R >
|
||||
static BOOST_DEDUCED_TYPENAME ::boost::tuples::element<N,tuple_t>::type begin( Z& z, R& )
|
||||
{
|
||||
return get<N>( z.begin().get_iterator_tuple() );
|
||||
}
|
||||
|
||||
template< class Z, class R >
|
||||
static BOOST_DEDUCED_TYPENAME ::boost::tuples::element<N,tuple_t>::type end( Z& z, R& r )
|
||||
{
|
||||
return get<N>( z.end().get_iterator_tuple() );
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template< class Rng1, class Rng2 >
|
||||
struct zip_range
|
||||
: iterator_range<
|
||||
zip_iterator<
|
||||
::boost::tuples::tuple<
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng1>::type,
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng2>::type
|
||||
>
|
||||
>
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef zip_iterator<
|
||||
::boost::tuples::tuple<
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng1>::type,
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng2>::type
|
||||
>
|
||||
> zip_iter_t;
|
||||
typedef iterator_range<zip_iter_t> base_t;
|
||||
|
||||
public:
|
||||
zip_range( Rng1& r1, Rng2& r2 )
|
||||
: base_t( zip_iter_t( ::boost::tuples::make_tuple(::boost::begin(r1),
|
||||
::boost::begin(r2)) ),
|
||||
zip_iter_t( ::boost::tuples::make_tuple(::boost::end(r1),
|
||||
::boost::end(r2)) ) )
|
||||
{
|
||||
BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r2));
|
||||
}
|
||||
};
|
||||
|
||||
template< class Rng1, class Rng2, class Rng3 >
|
||||
struct zip_range3
|
||||
: iterator_range<
|
||||
zip_iterator<
|
||||
::boost::tuples::tuple<
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng1>::type,
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng2>::type,
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng3>::type
|
||||
>
|
||||
>
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef zip_iterator<
|
||||
::boost::tuples::tuple<
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng1>::type,
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng2>::type,
|
||||
BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng3>::type
|
||||
>
|
||||
> zip_iter_t;
|
||||
typedef iterator_range<zip_iter_t> base_t;
|
||||
|
||||
public:
|
||||
zip_range3( Rng1& r1, Rng2& r2, Rng3& r3 )
|
||||
: base_t( zip_iter_t( ::boost::tuples::make_tuple(::boost::begin(r1),
|
||||
::boost::begin(r2),
|
||||
::boost::begin(r3)) ),
|
||||
zip_iter_t( ::boost::tuples::make_tuple(::boost::end(r1),
|
||||
::boost::end(r2),
|
||||
::boost::end(r3)) )
|
||||
)
|
||||
{
|
||||
BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r2));
|
||||
BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r3));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct combine_tag {};
|
||||
|
||||
template< class Rng >
|
||||
inline zip_rng<Rng>
|
||||
operator&( combine_tag, Rng& r )
|
||||
{
|
||||
return zip_rng<Rng>(r);
|
||||
}
|
||||
|
||||
template< class Rng >
|
||||
inline iterator_range<const Rng>
|
||||
operator&( combine_tag, const Rng& r )
|
||||
{
|
||||
return iterator_range<const Rng>(r);
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
class R1,
|
||||
class R2,
|
||||
class R3,
|
||||
class R4,
|
||||
class R5,
|
||||
class Rng
|
||||
>
|
||||
inline BOOST_DEDUCED_TYPENAME zip_rng<R1,R2,R3,R4,R5>::next
|
||||
operator&( const zip_rng<R1,R2,R3,R4,R5>& zip,
|
||||
Rng& r )
|
||||
{
|
||||
return zip_rng<R1,R2,R3,R4,R5>::next( zip, r );
|
||||
}
|
||||
|
||||
} // namespace range_detail
|
||||
|
||||
template< class Rng1, class Rng2 >
|
||||
inline ::boost::range_detail::zip_range<Rng1, Rng2> combine( Rng1& r1, Rng2& r2 )
|
||||
{
|
||||
return ::boost::range_detail::zip_range<Rng1, Rng2>(r1, r2);
|
||||
}
|
||||
|
||||
template< class Rng1, class Rng2 >
|
||||
inline ::boost::range_detail::zip_range<const Rng1, Rng2> combine( const Rng1& r1, Rng2& r2 )
|
||||
{
|
||||
return ::boost::range_detail::zip_range<const Rng1, Rng2>(r1, r2);
|
||||
}
|
||||
|
||||
template< class Rng1, class Rng2 >
|
||||
inline ::boost::range_detail::zip_range<Rng1, const Rng2> combine( Rng1& r1, const Rng2& r2 )
|
||||
{
|
||||
return ::boost::range_detail::zip_range<Rng1, const Rng2>(r1, r2);
|
||||
}
|
||||
|
||||
template< class Rng1, class Rng2 >
|
||||
inline ::boost::range_detail::zip_range<const Rng1, const Rng2> combine( const Rng1& r1, const Rng2& r2 )
|
||||
{
|
||||
return ::boost::range_detail::zip_range<const Rng1, const Rng2>(r1, r2);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace range
|
||||
} // namespace boost
|
||||
|
||||
#if defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) || \
|
||||
defined(BOOST_NO_CXX11_DECLTYPE) || \
|
||||
defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || \
|
||||
defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
# include <boost/range/detail/combine_cxx03.hpp>
|
||||
#else
|
||||
# include <boost/range/detail/combine_cxx11.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -72,6 +72,13 @@ namespace boost {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GCCXML__
|
||||
// GCC XML, unsurprisingly, has the same issues
|
||||
#if __GCCXML_GNUC__ == 4 && __GCCXML_GNUC_MINOR__ == 2
|
||||
#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
|
||||
#endif
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <boost/range/detail/extract_optional_type.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
@ -29,33 +30,45 @@ namespace boost
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace range_detail {
|
||||
BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( const_iterator )
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
struct range_const_iterator : range_detail::extract_const_iterator<C>
|
||||
{};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_const_iterator< std::pair<Iterator,Iterator> >
|
||||
namespace range_detail
|
||||
{
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_const_iterator< T[sz] >
|
||||
{
|
||||
typedef const T* type;
|
||||
};
|
||||
BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( const_iterator )
|
||||
|
||||
template< typename C >
|
||||
struct range_const_iterator
|
||||
: extract_const_iterator<C>
|
||||
{};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_const_iterator<std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_const_iterator< T[sz] >
|
||||
{
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
} // namespace range_detail
|
||||
|
||||
template<typename C>
|
||||
struct range_const_iterator
|
||||
: range_detail::range_const_iterator<
|
||||
BOOST_DEDUCED_TYPENAME remove_reference<C>::type
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -24,7 +25,9 @@ namespace boost
|
||||
//
|
||||
|
||||
template< typename C >
|
||||
struct range_const_reverse_iterator : range_reverse_iterator<const C>
|
||||
struct range_const_reverse_iterator
|
||||
: range_reverse_iterator<
|
||||
const BOOST_DEDUCED_TYPENAME remove_reference<C>::type>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
131
include/boost/range/detail/combine_cxx03.hpp
Normal file
131
include/boost/range/detail/combine_cxx03.hpp
Normal file
@ -0,0 +1,131 @@
|
||||
// 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_DETAIL_COMBINE_CXX03_HPP
|
||||
#define BOOST_RANGE_DETAIL_COMBINE_CXX03_HPP
|
||||
|
||||
#ifndef BOOST_RANGE_MIN_COMBINE_ARGS
|
||||
#define BOOST_RANGE_MIN_COMBINE_ARGS 2
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_RANGE_MAX_COMBINE_ARGS
|
||||
#define BOOST_RANGE_MAX_COMBINE_ARGS 5
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/iterator/zip_iterator.hpp>
|
||||
#include <boost/preprocessor/arithmetic/dec.hpp>
|
||||
#include <boost/preprocessor/arithmetic/div.hpp>
|
||||
#include <boost/preprocessor/arithmetic/mul.hpp>
|
||||
#include <boost/preprocessor/control.hpp>
|
||||
#include <boost/preprocessor/control/while.hpp>
|
||||
#include <boost/preprocessor/facilities/empty.hpp>
|
||||
#include <boost/preprocessor/facilities/identity.hpp>
|
||||
#include <boost/preprocessor/iteration/local.hpp>
|
||||
#include <boost/preprocessor/punctuation/comma.hpp>
|
||||
#include <boost/preprocessor/repetition.hpp>
|
||||
#include <boost/preprocessor/tuple/elem.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/mpl/transform.hpp>
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
|
||||
template<typename F, typename T, int SIZE>
|
||||
struct combined_result_impl;
|
||||
|
||||
template<typename F, typename T>
|
||||
struct combined_result
|
||||
: combined_result_impl<F, T, tuples::length<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#define BOOST_RANGE_combined_element(z, n, data) \
|
||||
typename tuples::element<n, T>::type
|
||||
|
||||
#define BOOST_RANGE_combined_result(z, n, data) \
|
||||
template<typename F, typename T> \
|
||||
struct combined_result_impl <F,T,n> \
|
||||
: result_of<F(BOOST_PP_ENUM(n, BOOST_RANGE_combined_element, ~))> \
|
||||
{ \
|
||||
};
|
||||
|
||||
#define BOOST_PP_LOCAL_MACRO(n) BOOST_RANGE_combined_result(~,n,~)
|
||||
|
||||
#define BOOST_PP_LOCAL_LIMITS (BOOST_RANGE_MIN_COMBINE_ARGS, \
|
||||
BOOST_RANGE_MAX_COMBINE_ARGS)
|
||||
#include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
#define BOOST_RANGE_combined_get(z, n, data) get<n>(tuple)
|
||||
|
||||
#define BOOST_RANGE_combined_unpack(z, n, data) \
|
||||
template<typename F, typename T> inline \
|
||||
typename combined_result<F,T>::type \
|
||||
unpack_(mpl::int_<n>, F f, const T& tuple) \
|
||||
{ \
|
||||
return f(BOOST_PP_ENUM(n, BOOST_RANGE_combined_get, ~)); \
|
||||
}
|
||||
|
||||
#define BOOST_PP_LOCAL_MACRO(n) BOOST_RANGE_combined_unpack(~,n,~)
|
||||
#define BOOST_PP_LOCAL_LIMITS (BOOST_RANGE_MIN_COMBINE_ARGS, \
|
||||
BOOST_RANGE_MAX_COMBINE_ARGS)
|
||||
#include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
} // namespace range_detail
|
||||
|
||||
namespace range
|
||||
{
|
||||
|
||||
#define BOOST_RANGE_combined_seq(z, n, data) boost::data(BOOST_PP_CAT(r,n))
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
|
||||
#include <boost/range/detail/combine_no_rvalue.hpp>
|
||||
|
||||
#else // by using rvalue references we avoid requiring 2^n overloads.
|
||||
|
||||
#include <boost/range/detail/combine_rvalue.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
#define BOOST_PP_LOCAL_MACRO(n) BOOST_RANGE_combine(~,n,~)
|
||||
#define BOOST_PP_LOCAL_LIMITS (BOOST_RANGE_MIN_COMBINE_ARGS, \
|
||||
BOOST_RANGE_MAX_COMBINE_ARGS)
|
||||
#include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
} // namespace range
|
||||
|
||||
using boost::range::combine;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
|
||||
#undef BOOST_RANGE_combined_element
|
||||
#undef BOOST_RANGE_combined_result
|
||||
#undef BOOST_RANGE_combined_get
|
||||
#undef BOOST_RANGE_combined_unpack
|
||||
#undef BOOST_RANGE_combined_seq
|
||||
#undef BOOST_RANGE_combined_exp_pred
|
||||
#undef BOOST_RANGE_combined_exp_op
|
||||
#undef BOOST_RANGE_combined_exp
|
||||
#undef BOOST_RANGE_combined_bitset_pred
|
||||
#undef BOOST_RANGE_combined_bitset_op
|
||||
#undef BOOST_RANGE_combined_bitset
|
||||
#undef BOOST_RANGE_combined_range_iterator
|
||||
#undef BOOST_RANGE_combined_args
|
||||
#undef BOOST_RANGE_combine_impl
|
||||
#undef BOOST_RANGE_combine
|
40
include/boost/range/detail/combine_cxx11.hpp
Normal file
40
include/boost/range/detail/combine_cxx11.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
// 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_DETAIL_COMBINE_CXX11_HPP
|
||||
#define BOOST_RANGE_DETAIL_COMBINE_CXX11_HPP
|
||||
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/iterator/zip_iterator.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range
|
||||
{
|
||||
|
||||
template<typename... Ranges>
|
||||
auto combine(Ranges&&... rngs) ->
|
||||
combined_range<decltype(boost::make_tuple(boost::begin(rngs)...))>
|
||||
{
|
||||
return combined_range<decltype(boost::make_tuple(boost::begin(rngs)...))>(
|
||||
boost::make_tuple(boost::begin(rngs)...),
|
||||
boost::make_tuple(boost::end(rngs)...));
|
||||
}
|
||||
|
||||
} // namespace range
|
||||
|
||||
using range::combine;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
73
include/boost/range/detail/combine_no_rvalue.hpp
Normal file
73
include/boost/range/detail/combine_no_rvalue.hpp
Normal file
@ -0,0 +1,73 @@
|
||||
// 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/
|
||||
//
|
||||
#define BOOST_RANGE_combined_exp_pred(d, data) BOOST_PP_TUPLE_ELEM(3, 0, data)
|
||||
|
||||
#define BOOST_RANGE_combined_exp_op(d, data) \
|
||||
( \
|
||||
BOOST_PP_DEC( \
|
||||
BOOST_PP_TUPLE_ELEM(3, 0, data) \
|
||||
), \
|
||||
BOOST_PP_TUPLE_ELEM(3, 1, data), \
|
||||
BOOST_PP_MUL_D( \
|
||||
d, \
|
||||
BOOST_PP_TUPLE_ELEM(3, 2, data), \
|
||||
BOOST_PP_TUPLE_ELEM(3, 1, data) \
|
||||
) \
|
||||
)
|
||||
|
||||
#define BOOST_RANGE_combined_exp(x, n) \
|
||||
BOOST_PP_TUPLE_ELEM(3, 2, \
|
||||
BOOST_PP_WHILE(BOOST_RANGE_combined_exp_pred, \
|
||||
BOOST_RANGE_combined_exp_op, (n, x, 1)))
|
||||
|
||||
#define BOOST_RANGE_combined_bitset_pred(n, state) \
|
||||
BOOST_PP_TUPLE_ELEM(2,1,state)
|
||||
|
||||
#define BOOST_RANGE_combined_bitset_op(d, state) \
|
||||
(BOOST_PP_DIV_D(d, BOOST_PP_TUPLE_ELEM(2,0,state), 2), \
|
||||
BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(2,1,state)))
|
||||
|
||||
#define BOOST_RANGE_combined_bitset(i, n) \
|
||||
BOOST_PP_MOD(BOOST_PP_TUPLE_ELEM(2, 0, \
|
||||
BOOST_PP_WHILE(BOOST_RANGE_combined_bitset_pred, \
|
||||
BOOST_RANGE_combined_bitset_op, (i,n))), 2)
|
||||
|
||||
#define BOOST_RANGE_combined_range_iterator(z, n, i) \
|
||||
typename range_iterator< \
|
||||
BOOST_PP_CAT(R,n) \
|
||||
BOOST_PP_IF( \
|
||||
BOOST_RANGE_combined_bitset(i,n), \
|
||||
BOOST_PP_IDENTITY(const), \
|
||||
BOOST_PP_EMPTY)() \
|
||||
>::type
|
||||
|
||||
#define BOOST_RANGE_combined_args(z, n, i) \
|
||||
BOOST_PP_CAT(R, n) \
|
||||
BOOST_PP_IF(BOOST_RANGE_combined_bitset(i,n), const&, &) \
|
||||
BOOST_PP_CAT(r, n)
|
||||
|
||||
#define BOOST_RANGE_combine_impl(z, i, n)\
|
||||
template<BOOST_PP_ENUM_PARAMS(n, typename R)> \
|
||||
inline range::combined_range< \
|
||||
boost::tuple<BOOST_PP_ENUM(n, BOOST_RANGE_combined_range_iterator, i)> \
|
||||
> \
|
||||
combine(BOOST_PP_ENUM(n, BOOST_RANGE_combined_args, i)) \
|
||||
{ \
|
||||
typedef tuple< \
|
||||
BOOST_PP_ENUM(n, BOOST_RANGE_combined_range_iterator, i) \
|
||||
> rng_tuple_t; \
|
||||
return range::combined_range<rng_tuple_t>( \
|
||||
rng_tuple_t(BOOST_PP_ENUM(n, BOOST_RANGE_combined_seq, begin)), \
|
||||
rng_tuple_t(BOOST_PP_ENUM(n, BOOST_RANGE_combined_seq, end))); \
|
||||
}
|
||||
|
||||
|
||||
#define BOOST_RANGE_combine(z, n, data) \
|
||||
BOOST_PP_REPEAT(BOOST_RANGE_combined_exp(2,n), BOOST_RANGE_combine_impl, n)
|
32
include/boost/range/detail/combine_rvalue.hpp
Normal file
32
include/boost/range/detail/combine_rvalue.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
// 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/
|
||||
//
|
||||
#define BOOST_RANGE_combined_args(z, n, i) \
|
||||
BOOST_PP_CAT(R, n)&& BOOST_PP_CAT(r, n)
|
||||
|
||||
#define BOOST_RANGE_combined_range_iterator(z, n, i) \
|
||||
typename range_iterator< \
|
||||
typename remove_reference<BOOST_PP_CAT(R,n)>::type \
|
||||
>::type
|
||||
|
||||
|
||||
#define BOOST_RANGE_combine(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename R)> \
|
||||
inline range::combined_range< \
|
||||
tuple<BOOST_PP_ENUM(n, BOOST_RANGE_combined_range_iterator, ~)> \
|
||||
> \
|
||||
combine(BOOST_PP_ENUM(n, BOOST_RANGE_combined_args, ~)) \
|
||||
{ \
|
||||
typedef tuple< \
|
||||
BOOST_PP_ENUM(n, BOOST_RANGE_combined_range_iterator, ~) \
|
||||
> rng_tuple_t; \
|
||||
return range::combined_range<rng_tuple_t>( \
|
||||
rng_tuple_t(BOOST_PP_ENUM(n, BOOST_RANGE_combined_seq, begin)), \
|
||||
rng_tuple_t(BOOST_PP_ENUM(n, BOOST_RANGE_combined_seq, end))); \
|
||||
}
|
@ -18,11 +18,17 @@
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
struct range_difference : iterator_difference< typename range_iterator<T>::type >
|
||||
struct range_difference
|
||||
: iterator_difference<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<
|
||||
BOOST_DEDUCED_TYPENAME remove_reference<T>::type
|
||||
>::type
|
||||
>
|
||||
{ };
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost
|
||||
@ -67,12 +68,14 @@ namespace boost
|
||||
|
||||
template<class T>
|
||||
struct has_range_iterator
|
||||
: range_detail::has_range_iterator_impl<T>
|
||||
: range_detail::has_range_iterator_impl<
|
||||
BOOST_DEDUCED_TYPENAME remove_reference<T>::type>
|
||||
{};
|
||||
|
||||
template<class T>
|
||||
struct has_range_const_iterator
|
||||
: range_detail::has_range_const_iterator_impl<T>
|
||||
: range_detail::has_range_const_iterator_impl<
|
||||
BOOST_DEDUCED_TYPENAME remove_reference<T>::type>
|
||||
{};
|
||||
} // namespace boost
|
||||
|
||||
|
@ -57,10 +57,15 @@ namespace boost
|
||||
|
||||
#else
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
private:
|
||||
typedef typename remove_reference<C>::type param_t;
|
||||
|
||||
public:
|
||||
typedef typename mpl::eval_if_c<
|
||||
is_const<param_t>::value,
|
||||
range_const_iterator<typename remove_const<param_t>::type>,
|
||||
range_mutable_iterator<param_t>
|
||||
>::type type;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
@ -7,6 +7,10 @@
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
// Credits:
|
||||
// 'michel' reported Trac 9072 which included a patch for allowing references
|
||||
// to function types.
|
||||
//
|
||||
#ifndef BOOST_RANGE_ITERATOR_RANGE_CORE_HPP_INCLUDED
|
||||
#define BOOST_RANGE_ITERATOR_RANGE_CORE_HPP_INCLUDED
|
||||
|
||||
@ -25,6 +29,7 @@
|
||||
#include <boost/type_traits/is_abstract.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
@ -300,6 +305,9 @@ public:
|
||||
>,
|
||||
boost::is_array<
|
||||
BOOST_DEDUCED_TYPENAME base_type::value_type
|
||||
>,
|
||||
boost::is_function<
|
||||
BOOST_DEDUCED_TYPENAME base_type::value_type
|
||||
>
|
||||
>,
|
||||
BOOST_DEDUCED_TYPENAME base_type::reference,
|
||||
|
22
include/boost/range/iterator_range_hash.hpp
Normal file
22
include/boost/range/iterator_range_hash.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
// 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/
|
||||
//
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T>
|
||||
std::size_t hash_value(const iterator_range<T>& rng)
|
||||
{
|
||||
return boost::hash_range(rng.begin(), rng.end());
|
||||
}
|
||||
|
||||
} // namespace boost
|
@ -19,12 +19,14 @@
|
||||
|
||||
|
||||
#include <boost/range/detail/extract_optional_type.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -34,7 +36,9 @@ namespace boost
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
struct range_mutable_iterator : range_detail::extract_iterator<C>
|
||||
struct range_mutable_iterator
|
||||
: range_detail::extract_iterator<
|
||||
BOOST_DEDUCED_TYPENAME remove_reference<C>::type>
|
||||
{};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -22,7 +22,8 @@
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
struct range_pointer : iterator_pointer< typename range_iterator<T>::type >
|
||||
struct range_pointer
|
||||
: iterator_pointer< BOOST_DEDUCED_TYPENAME range_iterator<T>::type >
|
||||
{ };
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/iterator/reverse_iterator.hpp>
|
||||
|
||||
|
||||
@ -30,7 +31,8 @@ namespace boost
|
||||
struct range_reverse_iterator
|
||||
{
|
||||
typedef reverse_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<C>::type > type;
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<
|
||||
BOOST_DEDUCED_TYPENAME remove_reference<C>::type>::type > type;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user