fix index_tuple

This commit is contained in:
bolero-MURAKAMI 2013-01-25 15:14:29 +09:00
parent 48f1b2d615
commit ee8602f6a3
42 changed files with 927 additions and 101 deletions

View file

@ -6,10 +6,11 @@
#include <sprout/container/traits.hpp> #include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/iterator/merge_iterator.hpp>
#include <sprout/functional/less.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit.hpp> #include <sprout/pit.hpp>
#include <sprout/detail/container_complate.hpp> #include <sprout/detail/container_complate.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -67,12 +68,12 @@ namespace sprout {
: sprout::detail::container_complate(result, args...) : sprout::detail::container_complate(result, args...)
; ;
} }
} // namespace detail
//
// merge
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare> template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename std::enable_if<
sprout::is_fixed_container<Result>::value,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type
merge( merge(
InputIterator1 first1, InputIterator1 last1, InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, InputIterator2 first2, InputIterator2 last2,
@ -86,6 +87,38 @@ namespace sprout {
sprout::size(result) sprout::size(result)
); );
} }
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename std::enable_if<
!sprout::is_fixed_container<Result>::value,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type
merge(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Result const& result, Compare comp
)
{
return sprout::remake<Result>(
result, sprout::size(result),
sprout::make_merge_iterator(first1, last1, first2, last2, comp),
sprout::make_merge_iterator(last1, last1, last2, last2, comp)
);
}
} // namespace detail
//
// merge
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
merge(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Result const& result, Compare comp
)
{
return sprout::fixed::detail::merge(first1, last1, first2, last2, result, comp);
}
template<typename InputIterator1, typename InputIterator2, typename Result> template<typename InputIterator1, typename InputIterator2, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
merge( merge(
@ -94,12 +127,7 @@ namespace sprout {
Result const& result Result const& result
) )
{ {
return sprout::fixed::detail::merge_impl( return sprout::fixed::merge(first1, last1, first2, last2, result, sprout::less<>());
first1, last1,
first2, last2,
result, NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Result>::value_type>(),
sprout::size(result)
);
} }
template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare> template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare>

View file

@ -6,10 +6,10 @@
#include <sprout/container/traits.hpp> #include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/functional/less.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit.hpp> #include <sprout/pit.hpp>
#include <sprout/detail/container_complate.hpp> #include <sprout/detail/container_complate.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -72,12 +72,12 @@ namespace sprout {
: sprout::detail::container_complate(result, args...) : sprout::detail::container_complate(result, args...)
; ;
} }
} // namespace detail
//
// set_difference
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare> template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename std::enable_if<
sprout::is_fixed_container<Result>::value,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type
set_difference( set_difference(
InputIterator1 first1, InputIterator1 last1, InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, InputIterator2 first2, InputIterator2 last2,
@ -91,6 +91,20 @@ namespace sprout {
sprout::size(result) sprout::size(result)
); );
} }
} // namespace detail
//
// set_difference
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_difference(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Result const& result, Compare comp
)
{
return sprout::fixed::detail::set_difference(first1, last1, first2, last2, result, comp);
}
template<typename InputIterator1, typename InputIterator2, typename Result> template<typename InputIterator1, typename InputIterator2, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_difference( set_difference(
@ -99,12 +113,7 @@ namespace sprout {
Result const& result Result const& result
) )
{ {
return sprout::fixed::detail::set_difference_impl( return sprout::fixed::set_difference(first1, last1, first2, last2, result, sprout::less<>());
first1, last1,
first2, last2,
result, NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Result>::value_type>(),
sprout::size(result)
);
} }
template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare> template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare>

View file

@ -6,10 +6,10 @@
#include <sprout/container/traits.hpp> #include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/functional/less.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit.hpp> #include <sprout/pit.hpp>
#include <sprout/detail/container_complate.hpp> #include <sprout/detail/container_complate.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -72,12 +72,12 @@ namespace sprout {
: sprout::detail::container_complate(result, args...) : sprout::detail::container_complate(result, args...)
; ;
} }
} // namespace detail
//
// set_intersection
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare> template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename std::enable_if<
sprout::is_fixed_container<Result>::value,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type
set_intersection( set_intersection(
InputIterator1 first1, InputIterator1 last1, InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, InputIterator2 first2, InputIterator2 last2,
@ -91,6 +91,20 @@ namespace sprout {
sprout::size(result) sprout::size(result)
); );
} }
} // namespace detail
//
// set_intersection
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_intersection(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Result const& result, Compare comp
)
{
return sprout::fixed::detail::set_intersection(first1, last1, first2, last2, result, comp);
}
template<typename InputIterator1, typename InputIterator2, typename Result> template<typename InputIterator1, typename InputIterator2, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_intersection( set_intersection(
@ -99,12 +113,7 @@ namespace sprout {
Result const& result Result const& result
) )
{ {
return sprout::fixed::detail::set_intersection_impl( return sprout::fixed::set_intersection(first1, last1, first2, last2, result, sprout::less<>());
first1, last1,
first2, last2,
result, NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Result>::value_type>(),
sprout::size(result)
);
} }
template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare> template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare>

View file

@ -6,10 +6,10 @@
#include <sprout/container/traits.hpp> #include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/functional/less.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit.hpp> #include <sprout/pit.hpp>
#include <sprout/detail/container_complate.hpp> #include <sprout/detail/container_complate.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -72,12 +72,12 @@ namespace sprout {
: sprout::detail::container_complate(result, args...) : sprout::detail::container_complate(result, args...)
; ;
} }
} // namespace detail
//
// set_symmetric_difference
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare> template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename std::enable_if<
sprout::is_fixed_container<Result>::value,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type
set_symmetric_difference( set_symmetric_difference(
InputIterator1 first1, InputIterator1 last1, InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, InputIterator2 first2, InputIterator2 last2,
@ -91,6 +91,20 @@ namespace sprout {
sprout::size(result) sprout::size(result)
); );
} }
} // namespace detail
//
// set_symmetric_difference
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_symmetric_difference(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Result const& result, Compare comp
)
{
return sprout::fixed::detail::set_symmetric_difference(first1, last1, first2, last2, result, comp);
}
template<typename InputIterator1, typename InputIterator2, typename Result> template<typename InputIterator1, typename InputIterator2, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_symmetric_difference( set_symmetric_difference(
@ -99,12 +113,7 @@ namespace sprout {
Result const& result Result const& result
) )
{ {
return sprout::fixed::detail::set_symmetric_difference_impl( return sprout::fixed::set_symmetric_difference(first1, last1, first2, last2, result, sprout::less<>());
first1, last1,
first2, last2,
result, NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Result>::value_type>(),
sprout::size(result)
);
} }
template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare> template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare>

View file

@ -6,10 +6,11 @@
#include <sprout/container/traits.hpp> #include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/iterator/set_union_iterator.hpp>
#include <sprout/functional/less.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit.hpp> #include <sprout/pit.hpp>
#include <sprout/detail/container_complate.hpp> #include <sprout/detail/container_complate.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -72,12 +73,12 @@ namespace sprout {
: sprout::detail::container_complate(result, args...) : sprout::detail::container_complate(result, args...)
; ;
} }
} // namespace detail
//
// set_union
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare> template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename std::enable_if<
sprout::is_fixed_container<Result>::value,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type
set_union( set_union(
InputIterator1 first1, InputIterator1 last1, InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, InputIterator2 first2, InputIterator2 last2,
@ -91,6 +92,38 @@ namespace sprout {
sprout::size(result) sprout::size(result)
); );
} }
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename std::enable_if<
!sprout::is_fixed_container<Result>::value,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type
set_union(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Result const& result, Compare comp
)
{
return sprout::remake<Result>(
result, sprout::size(result),
sprout::make_set_union_iterator(first1, last1, first2, last2, comp),
sprout::make_set_union_iterator(last1, last1, last2, last2, comp)
);
}
} // namespace detail
//
// set_union
//
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_union(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Result const& result, Compare comp
)
{
return sprout::fixed::detail::set_union(first1, last1, first2, last2, result, comp);
}
template<typename InputIterator1, typename InputIterator2, typename Result> template<typename InputIterator1, typename InputIterator2, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_union( set_union(
@ -99,12 +132,7 @@ namespace sprout {
Result const& result Result const& result
) )
{ {
return sprout::fixed::detail::set_union_impl( return sprout::fixed::set_union(first1, last1, first2, last2, result, sprout::less<>());
first1, last1,
first2, last2,
result, NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Result>::value_type>(),
sprout::size(result)
);
} }
template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare> template<typename Result, typename InputIterator1, typename InputIterator2, typename Compare>

View file

@ -61,6 +61,12 @@ namespace sprout {
; ;
} }
template<typename Result, typename InputIterator>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
unique_copy(InputIterator first, InputIterator last) {
return sprout::fixed::unique_copy(first, last, sprout::pit<Result>());
}
namespace detail { namespace detail {
template<typename InputIterator, typename Result, typename BinaryPredicate, typename Head, typename... Args> template<typename InputIterator, typename Result, typename BinaryPredicate, typename Head, typename... Args>
inline SPROUT_CONSTEXPR typename std::enable_if< inline SPROUT_CONSTEXPR typename std::enable_if<

View file

@ -50,8 +50,8 @@ namespace std {
// //
template<std::size_t I, typename T, std::size_t N> template<std::size_t I, typename T, std::size_t N>
struct tuple_element<I, sprout::array<T, N> > { struct tuple_element<I, sprout::array<T, N> > {
public:
static_assert(I < N, "tuple_element<>: index out of range"); static_assert(I < N, "tuple_element<>: index out of range");
public:
typedef T type; typedef T type;
}; };
#if defined(__clang__) #if defined(__clang__)

View file

@ -3,6 +3,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/index_tuple/index_tuple.hpp> #include <sprout/index_tuple/index_tuple.hpp>
#include <sprout/index_tuple/tuple.hpp>
#include <sprout/index_tuple/make_indexes.hpp> #include <sprout/index_tuple/make_indexes.hpp>
#include <sprout/index_tuple/index_range.hpp> #include <sprout/index_tuple/index_range.hpp>
#include <sprout/index_tuple/index_n.hpp> #include <sprout/index_tuple/index_n.hpp>

View file

@ -6,7 +6,9 @@
namespace sprout { namespace sprout {
namespace detail { namespace detail {
template<typename IndexTupleType> template<typename IndexTupleType>
struct make_indexes_helper { struct make_indexes_helper
: public IndexTupleType::type
{
public: public:
typedef typename IndexTupleType::type type; typedef typename IndexTupleType::type type;
public: public:

View file

@ -32,8 +32,7 @@ namespace sprout {
struct index_n_impl; struct index_n_impl;
template<sprout::index_t I, std::size_t N> template<sprout::index_t I, std::size_t N>
struct index_n_impl< struct index_n_impl<
I, I, N,
N,
typename std::enable_if<(N == 0)>::type typename std::enable_if<(N == 0)>::type
> { > {
public: public:
@ -41,8 +40,7 @@ namespace sprout {
}; };
template<sprout::index_t I, std::size_t N> template<sprout::index_t I, std::size_t N>
struct index_n_impl< struct index_n_impl<
I, I, N,
N,
typename std::enable_if<(N == 1)>::type typename std::enable_if<(N == 1)>::type
> { > {
public: public:
@ -50,8 +48,7 @@ namespace sprout {
}; };
template<sprout::index_t I, std::size_t N> template<sprout::index_t I, std::size_t N>
struct index_n_impl< struct index_n_impl<
I, I, N,
N,
typename std::enable_if<(N > 1 && N % 2 == 0)>::type typename std::enable_if<(N > 1 && N % 2 == 0)>::type
> >
: public sprout::detail::index_n_next< : public sprout::detail::index_n_next<
@ -60,8 +57,7 @@ namespace sprout {
{}; {};
template<sprout::index_t I, std::size_t N> template<sprout::index_t I, std::size_t N>
struct index_n_impl< struct index_n_impl<
I, I, N,
N,
typename std::enable_if<(N > 1 && N % 2 == 1)>::type typename std::enable_if<(N > 1 && N % 2 == 1)>::type
> >
: public sprout::detail::index_n_next2< : public sprout::detail::index_n_next2<

View file

@ -32,9 +32,7 @@ namespace sprout {
struct index_range_impl; struct index_range_impl;
template<sprout::index_t First, sprout::index_t Step, std::size_t N> template<sprout::index_t First, sprout::index_t Step, std::size_t N>
struct index_range_impl< struct index_range_impl<
First, First, Step, N,
Step,
N,
typename std::enable_if<(N == 0)>::type typename std::enable_if<(N == 0)>::type
> { > {
public: public:
@ -42,9 +40,7 @@ namespace sprout {
}; };
template<sprout::index_t First, sprout::index_t Step, std::size_t N> template<sprout::index_t First, sprout::index_t Step, std::size_t N>
struct index_range_impl< struct index_range_impl<
First, First, Step, N,
Step,
N,
typename std::enable_if<(N == 1)>::type typename std::enable_if<(N == 1)>::type
> { > {
public: public:
@ -52,9 +48,7 @@ namespace sprout {
}; };
template<sprout::index_t First, sprout::index_t Step, std::size_t N> template<sprout::index_t First, sprout::index_t Step, std::size_t N>
struct index_range_impl< struct index_range_impl<
First, First, Step, N,
Step,
N,
typename std::enable_if<(N > 1 && N % 2 == 0)>::type typename std::enable_if<(N > 1 && N % 2 == 0)>::type
> >
: public sprout::detail::index_range_next< : public sprout::detail::index_range_next<
@ -64,9 +58,7 @@ namespace sprout {
{}; {};
template<sprout::index_t First, sprout::index_t Step, std::size_t N> template<sprout::index_t First, sprout::index_t Step, std::size_t N>
struct index_range_impl< struct index_range_impl<
First, First, Step, N,
Step,
N,
typename std::enable_if<(N > 1 && N % 2 == 1)>::type typename std::enable_if<(N > 1 && N % 2 == 1)>::type
> >
: public sprout::detail::index_range_next2< : public sprout::detail::index_range_next2<
@ -80,9 +72,7 @@ namespace sprout {
struct index_range struct index_range
: public sprout::detail::make_indexes_helper< : public sprout::detail::make_indexes_helper<
sprout::detail::index_range_impl< sprout::detail::index_range_impl<
First, First, Step, ((Last - First) + (Step - 1)) / Step
Step,
((Last - First) + (Step - 1)) / Step
> >
> >
{}; {};

View file

@ -17,7 +17,12 @@ namespace sprout {
struct index_tuple { struct index_tuple {
public: public:
typedef index_tuple type; typedef index_tuple type;
typedef sprout::index_t value_type;
public:
SPROUT_STATIC_CONSTEXPR std::size_t size = sizeof...(Indexes);
}; };
template<sprout::index_t... Indexes>
SPROUT_CONSTEXPR_OR_CONST std::size_t sprout::index_tuple<Indexes...>::size;
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_INDEX_TUPLE_INDEX_TUPLE_HPP #endif // #ifndef SPROUT_INDEX_TUPLE_INDEX_TUPLE_HPP

View file

@ -2,6 +2,7 @@
#define SPROUT_INDEX_TUPLE_PACK_INDEXES_HPP #define SPROUT_INDEX_TUPLE_PACK_INDEXES_HPP
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/index_tuple/index_range.hpp>
#include <sprout/index_tuple/detail/make_indexes_helper.hpp> #include <sprout/index_tuple/detail/make_indexes_helper.hpp>
namespace sprout { namespace sprout {

View file

@ -0,0 +1,37 @@
#ifndef SPROUT_INDEX_TUPLE_TUPLE_HPP
#define SPROUT_INDEX_TUPLE_TUPLE_HPP
#include <cstddef>
#include <tuple>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/index_tuple/index_tuple.hpp>
namespace std {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmismatched-tags"
#endif
//
// tuple_size
//
template<sprout::index_t... Indexes>
struct tuple_size<sprout::index_tuple<Indexes...> >
: public std::integral_constant<std::size_t, sizeof...(Indexes)>
{};
//
// tuple_element
//
template<std::size_t I, sprout::index_t... Indexes>
struct tuple_element<I, sprout::index_tuple<Indexes...> > {
static_assert(I < sizeof...(Indexes), "tuple_element<>: index out of range");
public:
typedef sprout::index_t type;
};
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
} // namespace std
#endif // #ifndef SPROUT_INDEX_TUPLE_TUPLE_HPP

View file

@ -15,6 +15,7 @@
#include <sprout/iterator/valued_iterator.hpp> #include <sprout/iterator/valued_iterator.hpp>
#include <sprout/iterator/joint_iterator.hpp> #include <sprout/iterator/joint_iterator.hpp>
#include <sprout/iterator/alternate_iterator.hpp> #include <sprout/iterator/alternate_iterator.hpp>
#include <sprout/iterator/merge_iterator.hpp>
#include <sprout/iterator/size_enum_iterator.hpp> #include <sprout/iterator/size_enum_iterator.hpp>
#include <sprout/iterator/bytes_iterator.hpp> #include <sprout/iterator/bytes_iterator.hpp>
#include <sprout/iterator/remake_iterator.hpp> #include <sprout/iterator/remake_iterator.hpp>

View file

@ -11,7 +11,6 @@
#include <sprout/iterator/type_traits/common.hpp> #include <sprout/iterator/type_traits/common.hpp>
#include <sprout/utility/swap.hpp> #include <sprout/utility/swap.hpp>
#include <sprout/utility/limited.hpp> #include <sprout/utility/limited.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout { namespace sprout {
// //

View file

@ -0,0 +1,241 @@
#ifndef SPROUT_ITERATOR_MERGE_ITERATOR_HPP
#define SPROUT_ITERATOR_MERGE_ITERATOR_HPP
#include <iterator>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/next.hpp>
#include <sprout/iterator/type_traits/common.hpp>
#include <sprout/utility/swap.hpp>
namespace sprout {
//
// merge_iterator
//
template<
typename LIterator, typename RIterator,
typename Compare = sprout::less<>
>
class merge_iterator
: public std::iterator<
typename sprout::min_iterator_category<
typename sprout::common_iterator_category<LIterator, RIterator>::type,
std::forward_iterator_tag
>::type,
typename sprout::common_iterator_value_type<LIterator, RIterator>::type,
typename sprout::common_iterator_difference_type<LIterator, RIterator>::type,
typename sprout::common_iterator_pointer<LIterator, RIterator>::type,
typename sprout::common_iterator_reference<LIterator, RIterator>::type
>
{
public:
typedef LIterator iterator_type;
typedef RIterator iterator2_type;
typedef Compare compare_type;
typedef typename sprout::min_iterator_category<
typename sprout::common_iterator_category<LIterator, RIterator>::type,
std::forward_iterator_tag
>::type iterator_category;
typedef typename sprout::common_iterator_value_type<LIterator, RIterator>::type value_type;
typedef typename sprout::common_iterator_difference_type<LIterator, RIterator>::type difference_type;
typedef typename sprout::common_iterator_pointer<LIterator, RIterator>::type pointer;
typedef typename sprout::common_iterator_reference<LIterator, RIterator>::type reference;
private:
static SPROUT_CONSTEXPR bool check_in_left(
iterator_type it1, iterator_type lst1,
iterator2_type it2, iterator2_type lst2,
Compare comp
)
{
return it1 != lst1 ? (it2 != lst2 ? !comp(*it2, *it1) : true)
: !(it2 != lst2)
;
}
protected:
iterator_type current1;
iterator_type lst1;
iterator2_type current2;
iterator2_type lst2;
Compare comp;
bool in_left;
public:
merge_iterator()
: current1(), lst1(), current2(), lst2(), comp(), in_left(true)
{}
merge_iterator(merge_iterator const&) = default;
SPROUT_CONSTEXPR merge_iterator(
iterator_type it1, iterator_type lst1,
iterator2_type it2, iterator2_type lst2,
Compare comp = Compare()
)
: current1(it1), lst1(lst1)
, current2(it2), lst2(lst2)
, comp(comp)
, in_left(check_in_left(it1, lst1, it2, lst2, comp))
{}
template<typename U, typename V, typename W>
SPROUT_CONSTEXPR merge_iterator(merge_iterator<U, V, W> const& it)
: current1(it.base()), lst1(it.last1())
, current2(it.base2()), lst2(it.last2())
, comp(it.compare())
, in_left(it.is_in_left())
{}
template<typename U, typename V, typename W>
merge_iterator& operator=(merge_iterator<U, V, W> const& it) {
merge_iterator temp(it);
temp.swap(*this);
return *this;
}
SPROUT_CONSTEXPR iterator_type base() const {
return current1;
}
SPROUT_CONSTEXPR iterator_type last1() const {
return lst1;
}
SPROUT_CONSTEXPR iterator2_type base2() const {
return current2;
}
SPROUT_CONSTEXPR iterator2_type last2() const {
return lst2;
}
SPROUT_CONSTEXPR Compare compare() const {
return comp;
}
SPROUT_CONSTEXPR bool is_in_left() const {
return in_left;
}
SPROUT_CONSTEXPR reference operator*() const {
return is_in_left() ? *current1 : *current2;
}
SPROUT_CONSTEXPR pointer operator->() const {
return &*(*this);
}
merge_iterator& operator++() {
if (current1 != lst1) {
if (current2 != lst2) {
if (comp(*current2, *current1)) {
++current2;
} else {
++current1;
}
} else {
++current1;
}
} else if (current2 != lst2) {
++current2;
}
in_left = check_in_left(current1, lst1, current2, lst2, comp);
return *this;
}
merge_iterator operator++(int) {
merge_iterator result(*this);
if (current1 != lst1) {
if (current2 != lst2) {
if (comp(*current2, *current1)) {
++current2;
} else {
++current1;
}
} else {
++current1;
}
} else if (current2 != lst2) {
++current2;
}
in_left = check_in_left(current1, lst1, current2, lst2, comp);
return result;
}
SPROUT_CONSTEXPR merge_iterator next() const {
return current1 != lst1
? current2 != lst2
? comp(*current2, *current1)
? merge_iterator(current1, lst1, sprout::next(current2), lst2, comp)
: merge_iterator(sprout::next(current1), lst1, current2, lst2, comp)
: merge_iterator(sprout::next(current1), lst1, current2, lst2, comp)
: current2 != lst2
? merge_iterator(current1, lst1, sprout::next(current2), lst2, comp)
: *this
;
}
void swap(merge_iterator& other)
SPROUT_NOEXCEPT_EXPR(
SPROUT_NOEXCEPT_EXPR(sprout::swap(current1, other.current1))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(lst1, other.lst1))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(current2, other.current2))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(lst2, other.lst2))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(comp, other.comp))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(in_left, other.in_left))
)
{
sprout::swap(current1, other.current1);
sprout::swap(lst1, other.lst1);
sprout::swap(current2, other.current2);
sprout::swap(lst2, other.lst2);
sprout::swap(comp, other.comp);
sprout::swap(in_left, other.in_left);
}
};
template<
typename LIterator1, typename RIterator1, typename Compare1,
typename LIterator2, typename RIterator2, typename Compare2
>
inline SPROUT_CONSTEXPR bool operator==(
sprout::merge_iterator<LIterator1, RIterator1, Compare1> const& lhs,
sprout::merge_iterator<LIterator2, RIterator2, Compare2> const& rhs
)
{
return lhs.base() == rhs.base() && lhs.base2() == rhs.base2();
}
template<
typename LIterator1, typename RIterator1, typename Compare1,
typename LIterator2, typename RIterator2, typename Compare2
>
inline SPROUT_CONSTEXPR bool operator!=(
sprout::merge_iterator<LIterator1, RIterator1, Compare1> const& lhs,
sprout::merge_iterator<LIterator2, RIterator2, Compare2> const& rhs
)
{
return !(lhs == rhs);
}
//
// make_merge_iterator
//
template<typename LIterator, typename RIterator, typename Compare>
inline SPROUT_CONSTEXPR sprout::merge_iterator<LIterator, RIterator, Compare>
make_merge_iterator(LIterator it1, LIterator lst1, RIterator it2, RIterator lst2, Compare comp) {
return sprout::merge_iterator<LIterator, RIterator, Compare>(it1, lst1, it2, lst2, comp);
}
template<typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::merge_iterator<LIterator, RIterator>
make_merge_iterator(LIterator it1, LIterator lst1, RIterator it2, RIterator lst2) {
return sprout::merge_iterator<LIterator, RIterator>(it1, lst1, it2, lst2);
}
//
// swap
//
template<typename LIterator, typename RIterator, typename Compare>
inline void
swap(
sprout::merge_iterator<LIterator, RIterator, Compare>& lhs,
sprout::merge_iterator<LIterator, RIterator, Compare>& rhs
)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))
{
lhs.swap(rhs);
}
//
// iterator_next
//
template<typename LIterator, typename RIterator, typename Compare>
inline SPROUT_CONSTEXPR sprout::merge_iterator<LIterator, RIterator, Compare>
iterator_next(sprout::merge_iterator<LIterator, RIterator, Compare> const& it) {
return it.next();
}
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_MERGE_ITERATOR_HPP

View file

@ -0,0 +1,249 @@
#ifndef SPROUT_ITERATOR_SET_UNION_ITERATOR_HPP
#define SPROUT_ITERATOR_SET_UNION_ITERATOR_HPP
#include <iterator>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/next.hpp>
#include <sprout/iterator/type_traits/common.hpp>
#include <sprout/utility/swap.hpp>
namespace sprout {
//
// set_union_iterator
//
template<
typename LIterator, typename RIterator,
typename Compare = sprout::less<>
>
class set_union_iterator
: public std::iterator<
typename sprout::min_iterator_category<
typename sprout::common_iterator_category<LIterator, RIterator>::type,
std::forward_iterator_tag
>::type,
typename sprout::common_iterator_value_type<LIterator, RIterator>::type,
typename sprout::common_iterator_difference_type<LIterator, RIterator>::type,
typename sprout::common_iterator_pointer<LIterator, RIterator>::type,
typename sprout::common_iterator_reference<LIterator, RIterator>::type
>
{
public:
typedef LIterator iterator_type;
typedef RIterator iterator2_type;
typedef Compare compare_type;
typedef typename sprout::min_iterator_category<
typename sprout::common_iterator_category<LIterator, RIterator>::type,
std::forward_iterator_tag
>::type iterator_category;
typedef typename sprout::common_iterator_value_type<LIterator, RIterator>::type value_type;
typedef typename sprout::common_iterator_difference_type<LIterator, RIterator>::type difference_type;
typedef typename sprout::common_iterator_pointer<LIterator, RIterator>::type pointer;
typedef typename sprout::common_iterator_reference<LIterator, RIterator>::type reference;
private:
static SPROUT_CONSTEXPR bool check_in_left(
iterator_type it1, iterator_type lst1,
iterator2_type it2, iterator2_type lst2,
Compare comp
)
{
return it1 != lst1 ? (it2 != lst2 ? comp(*it1, *it2) || !comp(*it2, *it1) : true)
: !(it2 != lst2)
;
}
protected:
iterator_type current1;
iterator_type lst1;
iterator2_type current2;
iterator2_type lst2;
Compare comp;
bool in_left;
public:
set_union_iterator()
: current1(), lst1(), current2(), lst2(), comp(), in_left(true)
{}
set_union_iterator(set_union_iterator const&) = default;
SPROUT_CONSTEXPR set_union_iterator(
iterator_type it1, iterator_type lst1,
iterator2_type it2, iterator2_type lst2,
Compare comp = Compare()
)
: current1(it1), lst1(lst1)
, current2(it2), lst2(lst2)
, comp(comp)
, in_left(check_in_left(it1, lst1, it2, lst2, comp))
{}
template<typename U, typename V, typename W>
SPROUT_CONSTEXPR set_union_iterator(set_union_iterator<U, V, W> const& it)
: current1(it.base()), lst1(it.last1())
, current2(it.base2()), lst2(it.last2())
, comp(it.compare())
, in_left(it.is_in_left())
{}
template<typename U, typename V, typename W>
set_union_iterator& operator=(set_union_iterator<U, V, W> const& it) {
set_union_iterator temp(it);
temp.swap(*this);
return *this;
}
SPROUT_CONSTEXPR iterator_type base() const {
return current1;
}
SPROUT_CONSTEXPR iterator_type last1() const {
return lst1;
}
SPROUT_CONSTEXPR iterator2_type base2() const {
return current2;
}
SPROUT_CONSTEXPR iterator2_type last2() const {
return lst2;
}
SPROUT_CONSTEXPR Compare compare() const {
return comp;
}
SPROUT_CONSTEXPR bool is_in_left() const {
return in_left;
}
SPROUT_CONSTEXPR reference operator*() const {
return is_in_left() ? *current1 : *current2;
}
SPROUT_CONSTEXPR pointer operator->() const {
return &*(*this);
}
set_union_iterator& operator++() {
if (current1 != lst1) {
if (current2 != lst2) {
if (comp(*current1, *current2)) {
++current1;
} else if (comp(*current2, *current1)) {
++current2;
} else {
++current1;
++current2;
}
} else {
++current1;
}
} else if (current2 != lst2) {
++current2;
}
in_left = check_in_left(current1, lst1, current2, lst2, comp);
return *this;
}
set_union_iterator operator++(int) {
set_union_iterator result(*this);
if (current1 != lst1) {
if (current2 != lst2) {
if (comp(*current1, *current2)) {
++current1;
} else if (comp(*current2, *current1)) {
++current2;
} else {
++current1;
++current2;
}
} else {
++current1;
}
} else if (current2 != lst2) {
++current2;
}
in_left = check_in_left(current1, lst1, current2, lst2, comp);
return result;
}
SPROUT_CONSTEXPR set_union_iterator next() const {
return current1 != lst1
? current2 != lst2
? comp(*current1, *current2)
? set_union_iterator(sprout::next(current1), lst1, current2, lst2, comp)
: comp(*current2, *current1)
? set_union_iterator(current1, lst1, sprout::next(current2), lst2, comp)
: set_union_iterator(sprout::next(current1), lst1, sprout::next(current2), lst2, comp)
: set_union_iterator(sprout::next(current1), lst1, current2, lst2, comp)
: current2 != lst2
? set_union_iterator(current1, lst1, sprout::next(current2), lst2, comp)
: *this
;
}
void swap(set_union_iterator& other)
SPROUT_NOEXCEPT_EXPR(
SPROUT_NOEXCEPT_EXPR(sprout::swap(current1, other.current1))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(lst1, other.lst1))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(current2, other.current2))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(lst2, other.lst2))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(comp, other.comp))
&& SPROUT_NOEXCEPT_EXPR(sprout::swap(in_left, other.in_left))
)
{
sprout::swap(current1, other.current1);
sprout::swap(lst1, other.lst1);
sprout::swap(current2, other.current2);
sprout::swap(lst2, other.lst2);
sprout::swap(comp, other.comp);
sprout::swap(in_left, other.in_left);
}
};
template<
typename LIterator1, typename RIterator1, typename Compare1,
typename LIterator2, typename RIterator2, typename Compare2
>
inline SPROUT_CONSTEXPR bool operator==(
sprout::set_union_iterator<LIterator1, RIterator1, Compare1> const& lhs,
sprout::set_union_iterator<LIterator2, RIterator2, Compare2> const& rhs
)
{
return lhs.base() == rhs.base() && lhs.base2() == rhs.base2();
}
template<
typename LIterator1, typename RIterator1, typename Compare1,
typename LIterator2, typename RIterator2, typename Compare2
>
inline SPROUT_CONSTEXPR bool operator!=(
sprout::set_union_iterator<LIterator1, RIterator1, Compare1> const& lhs,
sprout::set_union_iterator<LIterator2, RIterator2, Compare2> const& rhs
)
{
return !(lhs == rhs);
}
//
// make_set_union_iterator
//
template<typename LIterator, typename RIterator, typename Compare>
inline SPROUT_CONSTEXPR sprout::set_union_iterator<LIterator, RIterator, Compare>
make_set_union_iterator(LIterator it1, LIterator lst1, RIterator it2, RIterator lst2, Compare comp) {
return sprout::set_union_iterator<LIterator, RIterator, Compare>(it1, lst1, it2, lst2, comp);
}
template<typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::set_union_iterator<LIterator, RIterator>
make_set_union_iterator(LIterator it1, LIterator lst1, RIterator it2, RIterator lst2) {
return sprout::set_union_iterator<LIterator, RIterator>(it1, lst1, it2, lst2);
}
//
// swap
//
template<typename LIterator, typename RIterator, typename Compare>
inline void
swap(
sprout::set_union_iterator<LIterator, RIterator, Compare>& lhs,
sprout::set_union_iterator<LIterator, RIterator, Compare>& rhs
)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))
{
lhs.swap(rhs);
}
//
// iterator_next
//
template<typename LIterator, typename RIterator, typename Compare>
inline SPROUT_CONSTEXPR sprout::set_union_iterator<LIterator, RIterator, Compare>
iterator_next(sprout::set_union_iterator<LIterator, RIterator, Compare> const& it) {
return it.next();
}
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_SET_UNION_ITERATOR_HPP

View file

@ -7,6 +7,8 @@
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit.hpp>
#include <sprout/detail/container_complate.hpp>
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -79,6 +81,12 @@ namespace sprout {
return sprout::fixed::detail::adjacent_difference_impl(first, last, result, sprout::size(result)); return sprout::fixed::detail::adjacent_difference_impl(first, last, result, sprout::size(result));
} }
template<typename Result, typename InputIterator>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
adjacent_difference(InputIterator first, InputIterator last) {
return sprout::fixed::adjacent_difference(first, last, sprout::pit<Result>());
}
namespace detail { namespace detail {
template<typename InputIterator, typename Result, typename BinaryOperation, typename... Args> template<typename InputIterator, typename Result, typename BinaryOperation, typename... Args>
inline SPROUT_CONSTEXPR typename std::enable_if< inline SPROUT_CONSTEXPR typename std::enable_if<
@ -147,6 +155,12 @@ namespace sprout {
adjacent_difference(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op) { adjacent_difference(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op) {
return sprout::fixed::detail::adjacent_difference_impl(first, last, result, binary_op, sprout::size(result)); return sprout::fixed::detail::adjacent_difference_impl(first, last, result, binary_op, sprout::size(result));
} }
template<typename Result, typename InputIterator, typename BinaryOperation>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
adjacent_difference(InputIterator first, InputIterator last, BinaryOperation binary_op) {
return sprout::fixed::adjacent_difference(first, last, sprout::pit<Result>(), binary_op);
}
} // namespace fixed } // namespace fixed
using sprout::fixed::adjacent_difference; using sprout::fixed::adjacent_difference;

View file

@ -6,7 +6,9 @@
#include <sprout/container/traits.hpp> #include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/iterator/counting_iterator.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit.hpp>
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -29,6 +31,33 @@ namespace sprout {
)... )...
); );
} }
template<typename Container, typename T>
inline SPROUT_CONSTEXPR typename std::enable_if<
sprout::is_fixed_container<Container>::value,
typename sprout::fixed::result_of::algorithm<Container>::type
>::type
iota(Container const& cont, T value) {
return sprout::fixed::detail::iota_impl(
cont, sprout::index_range<0, sprout::container_traits<Container>::static_size>::make(),
value,
sprout::internal_begin_offset(cont),
sprout::size(cont)
);
}
template<typename Container, typename T>
inline SPROUT_CONSTEXPR typename std::enable_if<
!sprout::is_fixed_container<Container>::value,
typename sprout::fixed::result_of::algorithm<Container>::type
>::type
iota(Container const& cont, T value) {
return sprout::remake<Container>(
cont, sprout::size(cont),
sprout::make_counting_iterator(value),
sprout::next(sprout::make_counting_iterator(value), sprout::size(cont))
);
}
} // namespace detail } // namespace detail
// //
// iota // iota
@ -36,13 +65,13 @@ namespace sprout {
template<typename Container, typename T> template<typename Container, typename T>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
iota(Container const& cont, T value) { iota(Container const& cont, T value) {
return sprout::fixed::detail::iota_impl( return sprout::fixed::detail::iota(cont, value);
cont, }
sprout::index_range<0, sprout::container_traits<Container>::static_size>::make(),
value, template<typename Container, typename T>
sprout::internal_begin_offset(cont), inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
sprout::size(cont) iota(T value) {
); return sprout::fixed::detail::iota(sprout::pit<Container>(), value);
} }
} // namespace fixed } // namespace fixed

View file

@ -7,6 +7,7 @@
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit.hpp>
#include <sprout/detail/container_complate.hpp> #include <sprout/detail/container_complate.hpp>
namespace sprout { namespace sprout {
@ -80,6 +81,12 @@ namespace sprout {
return sprout::fixed::detail::partial_sum_impl(first, last, result, sprout::size(result)); return sprout::fixed::detail::partial_sum_impl(first, last, result, sprout::size(result));
} }
template<typename Result, typename InputIterator>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
partial_sum(InputIterator first, InputIterator last) {
return sprout::fixed::partial_sum(first, last, sprout::pit<Result>());
}
namespace detail { namespace detail {
template<typename InputIterator, typename Result, typename BinaryOperation, typename... Args> template<typename InputIterator, typename Result, typename BinaryOperation, typename... Args>
inline SPROUT_CONSTEXPR typename std::enable_if< inline SPROUT_CONSTEXPR typename std::enable_if<
@ -148,6 +155,12 @@ namespace sprout {
partial_sum(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op) { partial_sum(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op) {
return sprout::fixed::detail::partial_sum_impl(first, last, result, binary_op, sprout::size(result)); return sprout::fixed::detail::partial_sum_impl(first, last, result, binary_op, sprout::size(result));
} }
template<typename Result, typename InputIterator, typename BinaryOperation>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
partial_sum(InputIterator first, InputIterator last, BinaryOperation binary_op) {
return sprout::fixed::partial_sum(first, last, sprout::pit<Result>(), binary_op);
}
} // namespace fixed } // namespace fixed
using sprout::fixed::partial_sum; using sprout::fixed::partial_sum;

View file

@ -34,6 +34,28 @@ namespace sprout {
{ {
return sprout::fixed::clamp_range_copy(sprout::begin(input), sprout::end(input), result, low, high); return sprout::fixed::clamp_range_copy(sprout::begin(input), sprout::end(input), result, low, high);
} }
template<typename Result, typename Input, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
clamp_range_copy(
Input const& input,
typename sprout::container_traits<Input>::value_type const& low,
typename sprout::container_traits<Input>::value_type const& high,
Compare comp
)
{
return sprout::fixed::clamp_range_copy<Result>(sprout::begin(input), sprout::end(input), low, high, comp);
}
template<typename Result, typename Input>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
clamp_range_copy(
Input const& input,
typename sprout::container_traits<Input>::value_type const& low,
typename sprout::container_traits<Input>::value_type const& high
)
{
return sprout::fixed::clamp_range_copy<Result>(sprout::begin(input), sprout::end(input), low, high);
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::clamp_range_copy; using sprout::range::fixed::clamp_range_copy;

View file

@ -18,6 +18,12 @@ namespace sprout {
copy_until(Input const& input, Result const& result, Predicate pred) { copy_until(Input const& input, Result const& result, Predicate pred) {
return sprout::fixed::copy_until(sprout::begin(input), sprout::end(input), result); return sprout::fixed::copy_until(sprout::begin(input), sprout::end(input), result);
} }
template<typename Result, typename Input, typename Predicate>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
copy_until(Input const& input, Predicate pred) {
return sprout::fixed::copy_until<Result>(sprout::begin(input), sprout::end(input));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::copy_until; using sprout::range::fixed::copy_until;

View file

@ -18,6 +18,12 @@ namespace sprout {
copy_while(Input const& input, Result const& result, Predicate pred) { copy_while(Input const& input, Result const& result, Predicate pred) {
return sprout::fixed::copy_while(sprout::begin(input), sprout::end(input), result); return sprout::fixed::copy_while(sprout::begin(input), sprout::end(input), result);
} }
template<typename Result, typename Input, typename Predicate>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
copy_while(Input const& input, Predicate pred) {
return sprout::fixed::copy_while<Result>(sprout::begin(input), sprout::end(input));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::copy_while; using sprout::range::fixed::copy_while;

View file

@ -23,6 +23,17 @@ namespace sprout {
merge(Input1 const& input1, Input2 const& input2, Result const& result) { merge(Input1 const& input1, Input2 const& input2, Result const& result) {
return sprout::fixed::merge(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); return sprout::fixed::merge(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result);
} }
template<typename Result, typename Input1, typename Input2, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
merge(Input1 const& input1, Input2 const& input2, Compare comp) {
return sprout::fixed::merge<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), comp);
}
template<typename Result, typename Input1, typename Input2>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
merge(Input1 const& input1, Input2 const& input2) {
return sprout::fixed::merge<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::merge; using sprout::range::fixed::merge;

View file

@ -18,6 +18,12 @@ namespace sprout {
partition_copy(Input const& input, Result const& result, Predicate pred) { partition_copy(Input const& input, Result const& result, Predicate pred) {
return sprout::fixed::partition_copy(sprout::begin(input), sprout::end(input), result, pred); return sprout::fixed::partition_copy(sprout::begin(input), sprout::end(input), result, pred);
} }
template<typename Result, typename Input, typename Predicate>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
partition_copy(Input const& input, Predicate pred) {
return sprout::fixed::partition_copy<Result>(sprout::begin(input), sprout::end(input), pred);
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::partition_copy; using sprout::range::fixed::partition_copy;

View file

@ -18,6 +18,12 @@ namespace sprout {
remove_copy(Input const& input, Result const& result, T const& value) { remove_copy(Input const& input, Result const& result, T const& value) {
return sprout::fixed::remove_copy(sprout::begin(input), sprout::end(input), result, value); return sprout::fixed::remove_copy(sprout::begin(input), sprout::end(input), result, value);
} }
template<typename Result, typename Input, typename T>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
remove_copy(Input const& input, Result const& result, T const& value) {
return sprout::fixed::remove_copy<Result>(sprout::begin(input), sprout::end(input), value);
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::remove_copy; using sprout::range::fixed::remove_copy;

View file

@ -18,6 +18,12 @@ namespace sprout {
remove_copy_if(Input const& input, Result const& result, Predicate pred) { remove_copy_if(Input const& input, Result const& result, Predicate pred) {
return sprout::fixed::remove_copy_if(sprout::begin(input), sprout::end(input), result, pred); return sprout::fixed::remove_copy_if(sprout::begin(input), sprout::end(input), result, pred);
} }
template<typename Result, typename Input, typename Predicate>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
remove_copy_if(Input const& input, Predicate pred) {
return sprout::fixed::remove_copy_if<Result>(sprout::begin(input), sprout::end(input), pred);
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::remove_copy_if; using sprout::range::fixed::remove_copy_if;

View file

@ -18,6 +18,12 @@ namespace sprout {
reverse_copy(Input const& input, Result const& result) { reverse_copy(Input const& input, Result const& result) {
return sprout::fixed::reverse_copy(sprout::begin(input), sprout::end(input), result); return sprout::fixed::reverse_copy(sprout::begin(input), sprout::end(input), result);
} }
template<typename Result, typename Input>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
reverse_copy(Input const& input) {
return sprout::fixed::reverse_copy<Result>(sprout::begin(input), sprout::end(input));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::reverse_copy; using sprout::range::fixed::reverse_copy;

View file

@ -22,6 +22,15 @@ namespace sprout {
{ {
return sprout::fixed::rotate_copy(sprout::begin(input), middle, sprout::end(input), result); return sprout::fixed::rotate_copy(sprout::begin(input), middle, sprout::end(input), result);
} }
template<typename Result, typename Input>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
rotate_copy(
Input const& input, typename sprout::container_traits<Input>::const_iterator middle
)
{
return sprout::fixed::rotate_copy<Result>(sprout::begin(input), middle, sprout::end(input));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::rotate_copy; using sprout::range::fixed::rotate_copy;

View file

@ -23,6 +23,17 @@ namespace sprout {
set_difference(Input1 const& input1, Input2 const& input2, Result const& result) { set_difference(Input1 const& input1, Input2 const& input2, Result const& result) {
return sprout::fixed::set_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); return sprout::fixed::set_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result);
} }
template<typename Result, typename Input1, typename Input2, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_difference(Input1 const& input1, Input2 const& input2, Compare comp) {
return sprout::fixed::set_difference<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), comp);
}
template<typename Result, typename Input1, typename Input2>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_difference(Input1 const& input1, Input2 const& input2) {
return sprout::fixed::set_difference<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::set_difference; using sprout::range::fixed::set_difference;

View file

@ -23,6 +23,17 @@ namespace sprout {
set_intersection(Input1 const& input1, Input2 const& input2, Result const& result) { set_intersection(Input1 const& input1, Input2 const& input2, Result const& result) {
return sprout::fixed::set_intersection(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); return sprout::fixed::set_intersection(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result);
} }
template<typename Result, typename Input1, typename Input2, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_intersection(Input1 const& input1, Input2 const& input2, Compare comp) {
return sprout::fixed::set_intersection<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), comp);
}
template<typename Result, typename Input1, typename Input2>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_intersection(Input1 const& input1, Input2 const& input2) {
return sprout::fixed::set_intersection<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::set_intersection; using sprout::range::fixed::set_intersection;

View file

@ -23,6 +23,17 @@ namespace sprout {
set_symmetric_difference(Input1 const& input1, Input2 const& input2, Result const& result) { set_symmetric_difference(Input1 const& input1, Input2 const& input2, Result const& result) {
return sprout::fixed::set_symmetric_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); return sprout::fixed::set_symmetric_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result);
} }
template<typename Result, typename Input1, typename Input2, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_symmetric_difference(Input1 const& input1, Input2 const& input2, Compare comp) {
return sprout::fixed::set_symmetric_difference<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), comp);
}
template<typename Result, typename Input1, typename Input2>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_symmetric_difference(Input1 const& input1, Input2 const& input2) {
return sprout::fixed::set_symmetric_difference<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::set_symmetric_difference; using sprout::range::fixed::set_symmetric_difference;

View file

@ -23,6 +23,17 @@ namespace sprout {
set_union(Input1 const& input1, Input2 const& input2, Result const& result) { set_union(Input1 const& input1, Input2 const& input2, Result const& result) {
return sprout::fixed::set_union(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); return sprout::fixed::set_union(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result);
} }
template<typename Result, typename Input1, typename Input2, typename Compare>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_union(Input1 const& input1, Input2 const& input2, Compare comp) {
return sprout::fixed::set_union<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), comp);
}
template<typename Result, typename Input1, typename Input2>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
set_union(Input1 const& input1, Input2 const& input2) {
return sprout::fixed::set_union<Result>(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::set_union; using sprout::range::fixed::set_union;

View file

@ -18,6 +18,12 @@ namespace sprout {
stable_partition_copy(Input const& input, Result const& result, Predicate pred) { stable_partition_copy(Input const& input, Result const& result, Predicate pred) {
return sprout::fixed::stable_partition_copy(sprout::begin(input), sprout::end(input), result, pred); return sprout::fixed::stable_partition_copy(sprout::begin(input), sprout::end(input), result, pred);
} }
template<typename Result, typename Input, typename Predicate>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
stable_partition_copy(Input const& input, Predicate pred) {
return sprout::fixed::stable_partition_copy<Result>(sprout::begin(input), sprout::end(input), pred);
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::stable_partition_copy; using sprout::range::fixed::stable_partition_copy;

View file

@ -23,6 +23,17 @@ namespace sprout {
{ {
return sprout::fixed::swap_element_copy(sprout::begin(input), sprout::end(input), result, pos1, pos2); return sprout::fixed::swap_element_copy(sprout::begin(input), sprout::end(input), result, pos1, pos2);
} }
template<typename Result, typename Input>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
swap_element_copy(
Input const& input,
typename sprout::container_traits<Input>::const_iterator pos1,
typename sprout::container_traits<Input>::const_iterator pos2
)
{
return sprout::fixed::swap_element_copy<Result>(sprout::begin(input), sprout::end(input), pos1, pos2);
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::swap_element_copy; using sprout::range::fixed::swap_element_copy;

View file

@ -23,6 +23,17 @@ namespace sprout {
unique_copy(Input const& input, Result const& result) { unique_copy(Input const& input, Result const& result) {
return sprout::fixed::unique_copy(sprout::begin(input), sprout::end(input), result); return sprout::fixed::unique_copy(sprout::begin(input), sprout::end(input), result);
} }
template<typename Result, typename Input, typename BinaryPredicate>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
unique_copy(Input const& input, BinaryPredicate pred) {
return sprout::fixed::unique_copy<Result>(sprout::begin(input), sprout::end(input), pred);
}
template<typename Result, typename Input>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
unique_copy(Input const& input) {
return sprout::fixed::unique_copy<Result>(sprout::begin(input), sprout::end(input));
}
} // namespace fixed } // namespace fixed
using sprout::range::fixed::unique_copy; using sprout::range::fixed::unique_copy;

View file

@ -50,8 +50,8 @@ namespace std {
// //
template<std::size_t I, typename T, std::size_t N, typename Traits> template<std::size_t I, typename T, std::size_t N, typename Traits>
struct tuple_element<I, sprout::basic_string<T, N, Traits> > { struct tuple_element<I, sprout::basic_string<T, N, Traits> > {
public:
static_assert(I < N, "tuple_element<>: index out of range"); static_assert(I < N, "tuple_element<>: index out of range");
public:
typedef T type; typedef T type;
}; };
#if defined(__clang__) #if defined(__clang__)

View file

@ -18,6 +18,7 @@ namespace sprout {
: public sprout::types::type_tuple<std::integral_constant<T, Values>...> : public sprout::types::type_tuple<std::integral_constant<T, Values>...>
{ {
public: public:
typedef integral_array type;
typedef T value_type; typedef T value_type;
}; };
} // namespace types } // namespace types

View file

@ -15,7 +15,10 @@ namespace sprout {
template<typename T, T... Values> template<typename T, T... Values>
struct basic_string struct basic_string
: public sprout::types::integral_array<T, Values...> : public sprout::types::integral_array<T, Values...>
{}; {
public:
typedef basic_string type;
};
} // namespace types } // namespace types
} // namespace sprout } // namespace sprout

View file

@ -18,9 +18,14 @@ namespace sprout {
template<typename... Types> template<typename... Types>
struct type_tuple { struct type_tuple {
public: public:
typedef type_tuple type;
typedef sprout::types::index_iterator<type_tuple, 0> begin; typedef sprout::types::index_iterator<type_tuple, 0> begin;
typedef sprout::types::index_iterator<type_tuple, sizeof...(Types)> end; typedef sprout::types::index_iterator<type_tuple, sizeof...(Types)> end;
public:
SPROUT_STATIC_CONSTEXPR std::size_t size = sizeof...(Types);
}; };
template<typename... Types>
SPROUT_CONSTEXPR_OR_CONST std::size_t sprout::types::type_tuple<Types...>::size;
// //
// rebind_types // rebind_types

View file

@ -52,8 +52,8 @@ namespace std {
// //
template<std::size_t I> template<std::size_t I>
struct tuple_element<I, sprout::uuids::uuid> { struct tuple_element<I, sprout::uuids::uuid> {
public:
static_assert(I < 16, "tuple_element<>: index out of range"); static_assert(I < 16, "tuple_element<>: index out of range");
public:
typedef sprout::uuids::uuid::value_type type; typedef sprout::uuids::uuid::value_type type;
}; };
#if defined(__clang__) #if defined(__clang__)