forked from boostorg/range
Merge branch 'develop'
This commit is contained in:
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))); \
|
||||
}
|
Reference in New Issue
Block a user