fix next, prev implementation and adapt-interface

This commit is contained in:
bolero-MURAKAMI 2012-09-26 16:31:11 +09:00
parent 69910ca06c
commit a4c7df65e0
19 changed files with 679 additions and 639 deletions

View file

@ -7,10 +7,29 @@
#include <sprout/type_traits/enabler_if.hpp> #include <sprout/type_traits/enabler_if.hpp>
#include <sprout/tuple/tuple/get.hpp> #include <sprout/tuple/tuple/get.hpp>
namespace sprout_generator_detail { namespace sprout {
struct not_found_adl_generated_value {}; namespace generators {
void generated_value();
} // namespace generators
} // namespace sprout
sprout_generator_detail::not_found_adl_generated_value generated_value(...); namespace sprout_generator_detail {
using sprout::tuples::get;
template<typename T>
struct has_spr_generated_value_test {
public:
template<
typename U = T,
typename = decltype(sprout::generators::generated_value(std::declval<U>()))
>
static std::true_type test(int);
static std::false_type test(...);
};
template<typename T>
struct has_spr_generated_value
: public decltype(sprout_generator_detail::has_spr_generated_value_test<T>::test(0))
{};
template<typename T> template<typename T>
struct has_mem_generated_value_test { struct has_mem_generated_value_test {
@ -27,29 +46,12 @@ namespace sprout_generator_detail {
: public decltype(sprout_generator_detail::has_mem_generated_value_test<T>::test(0)) : public decltype(sprout_generator_detail::has_mem_generated_value_test<T>::test(0))
{}; {};
template<typename T>
struct has_adl_generated_value_test {
public:
template<
typename U = T,
typename sprout::enabler_if<
!std::is_same<decltype(generated_value(std::declval<U>())), sprout_generator_detail::not_found_adl_generated_value>::value
>::type = sprout::enabler
>
static std::true_type test(int);
static std::false_type test(...);
};
template<typename T>
struct has_adl_generated_value
: public decltype(sprout_generator_detail::has_adl_generated_value_test<T>::test(0))
{};
template<typename T> template<typename T>
struct has_tuple_get_generated_value_test { struct has_tuple_get_generated_value_test {
public: public:
template< template<
typename U = T, typename U = T,
typename = decltype(sprout::tuples::get<0>(std::declval<U>())) typename = decltype(get<0>(std::declval<U>()))
> >
static std::true_type test(int); static std::true_type test(int);
static std::false_type test(...); static std::false_type test(...);
@ -60,40 +62,40 @@ namespace sprout_generator_detail {
{}; {};
template<typename T, typename Enable = void> template<typename T, typename Enable = void>
struct select_mem_generated_value; struct select_spr_generated_value;
template<typename T> template<typename T>
struct select_mem_generated_value< struct select_spr_generated_value<
T, T,
typename std::enable_if<sprout_generator_detail::has_mem_generated_value<T>::value>::type typename std::enable_if<sprout_generator_detail::has_spr_generated_value<T>::value>::type
> >
: public std::true_type : public std::true_type
{}; {};
template<typename T> template<typename T>
struct select_mem_generated_value< struct select_spr_generated_value<
T, T,
typename std::enable_if<!sprout_generator_detail::has_mem_generated_value<T>::value>::type typename std::enable_if<!sprout_generator_detail::has_spr_generated_value<T>::value>::type
> >
: public std::false_type : public std::false_type
{}; {};
template<typename T, typename Enable = void> template<typename T, typename Enable = void>
struct select_adl_generated_value; struct select_mem_generated_value;
template<typename T> template<typename T>
struct select_adl_generated_value< struct select_mem_generated_value<
T, T,
typename std::enable_if< typename std::enable_if<
sprout_generator_detail::has_adl_generated_value<T>::value sprout_generator_detail::has_mem_generated_value<T>::value
&& !sprout_generator_detail::has_mem_generated_value<T>::value && !sprout_generator_detail::has_spr_generated_value<T>::value
>::type >::type
> >
: public std::true_type : public std::true_type
{}; {};
template<typename T> template<typename T>
struct select_adl_generated_value< struct select_mem_generated_value<
T, T,
typename std::enable_if<!( typename std::enable_if<!(
sprout_generator_detail::has_adl_generated_value<T>::value sprout_generator_detail::has_mem_generated_value<T>::value
&& !sprout_generator_detail::has_mem_generated_value<T>::value && !sprout_generator_detail::has_spr_generated_value<T>::value
)>::type )>::type
> >
: public std::false_type : public std::false_type
@ -106,8 +108,8 @@ namespace sprout_generator_detail {
T, T,
typename std::enable_if< typename std::enable_if<
sprout_generator_detail::has_tuple_get_generated_value<T>::value sprout_generator_detail::has_tuple_get_generated_value<T>::value
&& !sprout_generator_detail::has_spr_generated_value<T>::value
&& !sprout_generator_detail::has_mem_generated_value<T>::value && !sprout_generator_detail::has_mem_generated_value<T>::value
&& !sprout_generator_detail::has_adl_generated_value<T>::value
>::type >::type
> >
: public std::true_type : public std::true_type
@ -117,8 +119,8 @@ namespace sprout_generator_detail {
T, T,
typename std::enable_if<!( typename std::enable_if<!(
sprout_generator_detail::has_tuple_get_generated_value<T>::value sprout_generator_detail::has_tuple_get_generated_value<T>::value
&& !sprout_generator_detail::has_spr_generated_value<T>::value
&& !sprout_generator_detail::has_mem_generated_value<T>::value && !sprout_generator_detail::has_mem_generated_value<T>::value
&& !sprout_generator_detail::has_adl_generated_value<T>::value
)>::type )>::type
> >
: public std::false_type : public std::false_type
@ -126,37 +128,47 @@ namespace sprout_generator_detail {
template<typename T, typename = void> template<typename T, typename = void>
struct noexcept_generated_value; struct noexcept_generated_value;
// template<typename T>
// struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_spr_generated_value<T>::value>::type>
// : public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(sprout::generators::generated_value(std::declval<T>()), false)>
// {};
template<typename T> template<typename T>
struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type> struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type>
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::declval<T>().generated_value(), false)> : public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::declval<T>().generated_value(), false)>
{}; {};
template<typename T> template<typename T>
struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_adl_generated_value<T>::value>::type>
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(generated_value(std::declval<T>()), false)>
{};
template<typename T>
struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_tuple_get_generated_value<T>::value>::type> struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_tuple_get_generated_value<T>::value>::type>
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(sprout::tuples::get<0>(std::declval<T>()), false)> : public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(get<0>(std::declval<T>()), false)>
{}; {};
template<typename T, typename = void> template<typename T, typename = void>
struct generated_value_result; struct generated_value_result;
// template<typename T>
// struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_spr_generated_value<T>::value>::type> {
// public:
// typedef decltype(sprout::generators::generated_value(std::declval<T>())) type;
// };
template<typename T> template<typename T>
struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type> { struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type> {
public: public:
typedef decltype(std::declval<T>().generated_value()) type; typedef decltype(std::declval<T>().generated_value()) type;
}; };
template<typename T> template<typename T>
struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_adl_generated_value<T>::value>::type> {
public:
typedef decltype(generated_value(std::declval<T>())) type;
};
template<typename T>
struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_tuple_get_generated_value<T>::value>::type> { struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_tuple_get_generated_value<T>::value>::type> {
public: public:
typedef decltype(sprout::tuples::get<0>(std::declval<T>())) type; typedef decltype(get<0>(std::declval<T>())) type;
}; };
// template<
// typename T,
// typename sprout::enabler_if<sprout_generator_detail::select_spr_generated_value<T>::value>::type = sprout::enabler
// >
// inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result<T>::type
// generated_value_impl(T&& t)
// SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value<T>::value))
// {
// return sprout::generators::generated_value(sprout::forward<T>(t));
// }
template< template<
typename T, typename T,
typename sprout::enabler_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type = sprout::enabler typename sprout::enabler_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type = sprout::enabler
@ -167,16 +179,6 @@ namespace sprout_generator_detail {
{ {
return sprout::forward<T>(t).generated_value(); return sprout::forward<T>(t).generated_value();
} }
template<
typename T,
typename sprout::enabler_if<sprout_generator_detail::select_adl_generated_value<T>::value>::type = sprout::enabler
>
inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result<T>::type
generated_value_impl(T&& t)
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value<T>::value))
{
return generated_value(sprout::forward<T>(t));
}
template< template<
typename T, typename T,
typename sprout::enabler_if<sprout_generator_detail::select_tuple_get_generated_value<T>::value>::type = sprout::enabler typename sprout::enabler_if<sprout_generator_detail::select_tuple_get_generated_value<T>::value>::type = sprout::enabler
@ -185,7 +187,7 @@ namespace sprout_generator_detail {
generated_value_impl(T&& t) generated_value_impl(T&& t)
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value<T>::value)) SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value<T>::value))
{ {
return sprout::tuples::get<0>(sprout::forward<T>(t)); return get<0>(sprout::forward<T>(t));
} }
} // namespace sprout_generator_detail } // namespace sprout_generator_detail

View file

@ -7,10 +7,29 @@
#include <sprout/type_traits/enabler_if.hpp> #include <sprout/type_traits/enabler_if.hpp>
#include <sprout/tuple/tuple/get.hpp> #include <sprout/tuple/tuple/get.hpp>
namespace sprout_generator_detail { namespace sprout {
struct not_found_adl_next_generator {}; namespace generators {
void next_generator();
} // namespace generators
} // namespace sprout
sprout_generator_detail::not_found_adl_next_generator next_generator(...); namespace sprout_generator_detail {
using sprout::tuples::get;
template<typename T>
struct has_spr_next_generator_test {
public:
template<
typename U = T,
typename = decltype(sprout::generators::next_generator(std::declval<U>()))
>
static std::true_type test(int);
static std::false_type test(...);
};
template<typename T>
struct has_spr_next_generator
: public decltype(sprout_generator_detail::has_spr_next_generator_test<T>::test(0))
{};
template<typename T> template<typename T>
struct has_mem_next_generator_test { struct has_mem_next_generator_test {
@ -27,29 +46,12 @@ namespace sprout_generator_detail {
: public decltype(sprout_generator_detail::has_mem_next_generator_test<T>::test(0)) : public decltype(sprout_generator_detail::has_mem_next_generator_test<T>::test(0))
{}; {};
template<typename T>
struct has_adl_next_generator_test {
public:
template<
typename U = T,
typename sprout::enabler_if<
!std::is_same<decltype(next_generator(std::declval<U>())), sprout_generator_detail::not_found_adl_next_generator>::value
>::type = sprout::enabler
>
static std::true_type test(int);
static std::false_type test(...);
};
template<typename T>
struct has_adl_next_generator
: public decltype(sprout_generator_detail::has_adl_next_generator_test<T>::test(0))
{};
template<typename T> template<typename T>
struct has_tuple_get_next_generator_test { struct has_tuple_get_next_generator_test {
public: public:
template< template<
typename U = T, typename U = T,
typename = decltype(sprout::tuples::get<1>(std::declval<U>())) typename = decltype(get<1>(std::declval<U>()))
> >
static std::true_type test(int); static std::true_type test(int);
static std::false_type test(...); static std::false_type test(...);
@ -60,40 +62,40 @@ namespace sprout_generator_detail {
{}; {};
template<typename T, typename Enable = void> template<typename T, typename Enable = void>
struct select_mem_next_generator; struct select_spr_next_generator;
template<typename T> template<typename T>
struct select_mem_next_generator< struct select_spr_next_generator<
T, T,
typename std::enable_if<sprout_generator_detail::has_mem_next_generator<T>::value>::type typename std::enable_if<sprout_generator_detail::has_spr_next_generator<T>::value>::type
> >
: public std::true_type : public std::true_type
{}; {};
template<typename T> template<typename T>
struct select_mem_next_generator< struct select_spr_next_generator<
T, T,
typename std::enable_if<!sprout_generator_detail::has_mem_next_generator<T>::value>::type typename std::enable_if<!sprout_generator_detail::has_spr_next_generator<T>::value>::type
> >
: public std::false_type : public std::false_type
{}; {};
template<typename T, typename Enable = void> template<typename T, typename Enable = void>
struct select_adl_next_generator; struct select_mem_next_generator;
template<typename T> template<typename T>
struct select_adl_next_generator< struct select_mem_next_generator<
T, T,
typename std::enable_if< typename std::enable_if<
sprout_generator_detail::has_adl_next_generator<T>::value sprout_generator_detail::has_mem_next_generator<T>::value
&& !sprout_generator_detail::has_mem_next_generator<T>::value && !sprout_generator_detail::has_spr_next_generator<T>::value
>::type >::type
> >
: public std::true_type : public std::true_type
{}; {};
template<typename T> template<typename T>
struct select_adl_next_generator< struct select_mem_next_generator<
T, T,
typename std::enable_if<!( typename std::enable_if<!(
sprout_generator_detail::has_adl_next_generator<T>::value sprout_generator_detail::has_mem_next_generator<T>::value
&& !sprout_generator_detail::has_mem_next_generator<T>::value && !sprout_generator_detail::has_spr_next_generator<T>::value
)>::type )>::type
> >
: public std::false_type : public std::false_type
@ -106,8 +108,8 @@ namespace sprout_generator_detail {
T, T,
typename std::enable_if< typename std::enable_if<
sprout_generator_detail::has_tuple_get_next_generator<T>::value sprout_generator_detail::has_tuple_get_next_generator<T>::value
&& !sprout_generator_detail::has_spr_next_generator<T>::value
&& !sprout_generator_detail::has_mem_next_generator<T>::value && !sprout_generator_detail::has_mem_next_generator<T>::value
&& !sprout_generator_detail::has_adl_next_generator<T>::value
>::type >::type
> >
: public std::true_type : public std::true_type
@ -117,8 +119,8 @@ namespace sprout_generator_detail {
T, T,
typename std::enable_if<!( typename std::enable_if<!(
sprout_generator_detail::has_tuple_get_next_generator<T>::value sprout_generator_detail::has_tuple_get_next_generator<T>::value
&& !sprout_generator_detail::has_spr_next_generator<T>::value
&& !sprout_generator_detail::has_mem_next_generator<T>::value && !sprout_generator_detail::has_mem_next_generator<T>::value
&& !sprout_generator_detail::has_adl_next_generator<T>::value
)>::type )>::type
> >
: public std::false_type : public std::false_type
@ -126,37 +128,47 @@ namespace sprout_generator_detail {
template<typename T, typename = void> template<typename T, typename = void>
struct noexcept_next_generator; struct noexcept_next_generator;
// template<typename T>
// struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_spr_next_generator<T>::value>::type>
// : public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(sprout::generators::next_generator(std::declval<T>()), false)>
// {};
template<typename T> template<typename T>
struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type> struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type>
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::declval<T>().next_generator(), false)> : public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::declval<T>().next_generator(), false)>
{}; {};
template<typename T> template<typename T>
struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_adl_next_generator<T>::value>::type>
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(next_generator(std::declval<T>()), false)>
{};
template<typename T>
struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_tuple_get_next_generator<T>::value>::type> struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_tuple_get_next_generator<T>::value>::type>
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(sprout::tuples::get<1>(std::declval<T>()), false)> : public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(get<1>(std::declval<T>()), false)>
{}; {};
template<typename T, typename = void> template<typename T, typename = void>
struct next_generator_result; struct next_generator_result;
// template<typename T>
// struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_spr_next_generator<T>::value>::type> {
// public:
// typedef decltype(sprout::generators::next_generator(std::declval<T>())) type;
// };
template<typename T> template<typename T>
struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type> { struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type> {
public: public:
typedef decltype(std::declval<T>().next_generator()) type; typedef decltype(std::declval<T>().next_generator()) type;
}; };
template<typename T> template<typename T>
struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_adl_next_generator<T>::value>::type> {
public:
typedef decltype(next_generator(std::declval<T>())) type;
};
template<typename T>
struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_tuple_get_next_generator<T>::value>::type> { struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_tuple_get_next_generator<T>::value>::type> {
public: public:
typedef decltype(sprout::tuples::get<1>(std::declval<T>())) type; typedef decltype(get<1>(std::declval<T>())) type;
}; };
// template<
// typename T,
// typename sprout::enabler_if<sprout_generator_detail::select_spr_next_generator<T>::value>::type = sprout::enabler
// >
// inline SPROUT_CONSTEXPR typename sprout_generator_detail::next_generator_result<T>::type
// next_generator_impl(T&& t)
// SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator<T>::value))
// {
// return sprout::generators::next_generator(sprout::forward<T>(t));
// }
template< template<
typename T, typename T,
typename sprout::enabler_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type = sprout::enabler typename sprout::enabler_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type = sprout::enabler
@ -167,16 +179,6 @@ namespace sprout_generator_detail {
{ {
return sprout::forward<T>(t).next_generator(); return sprout::forward<T>(t).next_generator();
} }
template<
typename T,
typename sprout::enabler_if<sprout_generator_detail::select_adl_next_generator<T>::value>::type = sprout::enabler
>
inline SPROUT_CONSTEXPR typename sprout_generator_detail::next_generator_result<T>::type
next_generator_impl(T&& t)
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator<T>::value))
{
return next_generator(sprout::forward<T>(t));
}
template< template<
typename T, typename T,
typename sprout::enabler_if<sprout_generator_detail::select_tuple_get_next_generator<T>::value>::type = sprout::enabler typename sprout::enabler_if<sprout_generator_detail::select_tuple_get_next_generator<T>::value>::type = sprout::enabler
@ -185,7 +187,7 @@ namespace sprout_generator_detail {
next_generator_impl(T&& t) next_generator_impl(T&& t)
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator<T>::value)) SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator<T>::value))
{ {
return sprout::tuples::get<1>(sprout::forward<T>(t)); return get<1>(sprout::forward<T>(t));
} }
} // namespace sprout_generator_detail } // namespace sprout_generator_detail

View file

@ -162,6 +162,18 @@ namespace sprout {
} }
}; };
//
// make_bytes_iterator
//
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator> make_bytes_iterator(Iterator it) {
return sprout::bytes_iterator<Iterator>(it);
}
template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> make_bytes_iterator(Iterator it, Traits) {
return sprout::bytes_iterator<Iterator, Traits>(it);
}
// //
// swap // swap
// //
@ -170,44 +182,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> next(
sprout::bytes_iterator<Iterator, Traits> const& it
)
{
return it.next();
}
template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> next(
sprout::bytes_iterator<Iterator, Traits> const& it,
typename sprout::bytes_iterator<Iterator, Traits>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> prev(
sprout::bytes_iterator<Iterator, Traits> const& it
)
{
return it.prev();
}
template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> prev(
sprout::bytes_iterator<Iterator, Traits> const& it,
typename sprout::bytes_iterator<Iterator, Traits>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -222,15 +196,41 @@ namespace sprout {
} }
// //
// make_bytes_iterator // iterator_next
// //
template<typename Iterator> template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator> make_bytes_iterator(Iterator it) { inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> iterator_next(
return sprout::bytes_iterator<Iterator>(it); sprout::bytes_iterator<Iterator, Traits> const& it
)
{
return it.next();
} }
template<typename Iterator, typename Traits> template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> make_bytes_iterator(Iterator it, Traits) { inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> iterator_next(
return sprout::bytes_iterator<Iterator, Traits>(it); sprout::bytes_iterator<Iterator, Traits> const& it,
typename sprout::bytes_iterator<Iterator, Traits>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> iterator_prev(
sprout::bytes_iterator<Iterator, Traits> const& it
)
{
return it.prev();
}
template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> iterator_prev(
sprout::bytes_iterator<Iterator, Traits> const& it,
typename sprout::bytes_iterator<Iterator, Traits>::difference_type n
)
{
return it - n;
} }
} // namespace sprout } // namespace sprout

View file

@ -190,44 +190,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename Incrementable>
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable> next(
sprout::counting_iterator<Incrementable> const& it
)
{
return it.next();
}
template<typename Incrementable>
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable> next(
sprout::counting_iterator<Incrementable> const& it,
typename sprout::counting_iterator<Incrementable>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Incrementable>
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable> prev(
sprout::counting_iterator<Incrementable> const& it
)
{
return it.prev();
}
template<typename Incrementable>
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable> prev(
sprout::counting_iterator<Incrementable> const& it,
typename sprout::counting_iterator<Incrementable>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -240,6 +202,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename Incrementable>
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable> iterator_next(
sprout::counting_iterator<Incrementable> const& it
)
{
return it.next();
}
template<typename Incrementable>
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable> iterator_next(
sprout::counting_iterator<Incrementable> const& it,
typename sprout::counting_iterator<Incrementable>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Incrementable>
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable> iterator_prev(
sprout::counting_iterator<Incrementable> const& it
)
{
return it.prev();
}
template<typename Incrementable>
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable> iterator_prev(
sprout::counting_iterator<Incrementable> const& it,
typename sprout::counting_iterator<Incrementable>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP

View file

@ -129,10 +129,10 @@ namespace sprout {
return temp; return temp;
} }
SPROUT_CONSTEXPR filter_iterator next() const { SPROUT_CONSTEXPR filter_iterator next() const {
return filter_iterator(pred, find_next(sprout::next(current)), last, private_constructor_tag()); return filter_iterator(pred, find_next(sprout::next(current), last, pred), last, private_constructor_tag());
} }
SPROUT_CONSTEXPR filter_iterator prev() const { SPROUT_CONSTEXPR filter_iterator prev() const {
return filter_iterator(pred, find_prev(sprout::prev(current)), last, private_constructor_tag()); return filter_iterator(pred, find_prev(sprout::prev(current), pred), last, private_constructor_tag());
} }
void swap(filter_iterator& other) { void swap(filter_iterator& other) {
using std::swap; using std::swap;
@ -177,10 +177,10 @@ namespace sprout {
} }
// //
// next // iterator_next
// //
template<typename Predicate, typename Iterator> template<typename Predicate, typename Iterator>
inline SPROUT_CONSTEXPR sprout::filter_iterator<Predicate, Iterator> next( inline SPROUT_CONSTEXPR sprout::filter_iterator<Predicate, Iterator> iterator_next(
sprout::filter_iterator<Predicate, Iterator> const& it sprout::filter_iterator<Predicate, Iterator> const& it
) )
{ {
@ -188,10 +188,10 @@ namespace sprout {
} }
// //
// prev // iterator_prev
// //
template<typename Predicate, typename Iterator> template<typename Predicate, typename Iterator>
inline SPROUT_CONSTEXPR sprout::filter_iterator<Predicate, Iterator> prev( inline SPROUT_CONSTEXPR sprout::filter_iterator<Predicate, Iterator> iterator_prev(
sprout::filter_iterator<Predicate, Iterator> const& it sprout::filter_iterator<Predicate, Iterator> const& it
) )
{ {

View file

@ -195,44 +195,6 @@ namespace sprout {
: public std::true_type : public std::true_type
{}; {};
//
// next
//
template<typename Container>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container> next(
sprout::index_iterator<Container> const& it
)
{
return it.next();
}
template<typename Container>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container> next(
sprout::index_iterator<Container> const& it,
typename sprout::index_iterator<Container>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Container>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container> prev(
sprout::index_iterator<Container> const& it
)
{
return it.prev();
}
template<typename Container>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container> prev(
sprout::index_iterator<Container> const& it,
typename sprout::index_iterator<Container>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -245,6 +207,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename Container>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container> iterator_next(
sprout::index_iterator<Container> const& it
)
{
return it.next();
}
template<typename Container>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container> iterator_next(
sprout::index_iterator<Container> const& it,
typename sprout::index_iterator<Container>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Container>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container> iterator_prev(
sprout::index_iterator<Container> const& it
)
{
return it.prev();
}
template<typename Container>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container> iterator_prev(
sprout::index_iterator<Container> const& it,
typename sprout::index_iterator<Container>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_INDEX_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_INDEX_ITERATOR_HPP

View file

@ -4,73 +4,94 @@
#include <iterator> #include <iterator>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
namespace detail { namespace iterator_detail {
template<typename RandomAccessIterator> template<typename RandomAccessIterator>
inline SPROUT_CONSTEXPR typename std::enable_if< inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value, std::is_literal_type<RandomAccessIterator>::value,
typename std::decay<RandomAccessIterator>::type RandomAccessIterator
>::type next_impl( >::type next_impl(
RandomAccessIterator&& it, RandomAccessIterator const& it,
std::random_access_iterator_tag* std::random_access_iterator_tag*
) )
{ {
return sprout::forward<RandomAccessIterator>(it) + 1; return it + 1;
} }
template<typename ForwardIterator> template<typename ForwardIterator>
inline SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type next_impl( inline SPROUT_CONSTEXPR ForwardIterator next_impl(
ForwardIterator&& it, ForwardIterator const& it,
void* void*
) )
{ {
return std::next(sprout::forward<ForwardIterator>(it)); return std::next(it);
} }
template<typename RandomAccessIterator> template<typename RandomAccessIterator>
inline SPROUT_CONSTEXPR typename std::enable_if< inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value, std::is_literal_type<RandomAccessIterator>::value,
typename std::decay<RandomAccessIterator>::type RandomAccessIterator
>::type next_impl( >::type next_impl(
RandomAccessIterator&& it, RandomAccessIterator const& it,
typename std::iterator_traits<typename std::decay<RandomAccessIterator>::type>::difference_type n, typename std::iterator_traits<RandomAccessIterator>::difference_type n,
std::random_access_iterator_tag* std::random_access_iterator_tag*
) )
{ {
return sprout::forward<RandomAccessIterator>(it) + n; return it + n;
} }
template<typename ForwardIterator> template<typename ForwardIterator>
inline SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type next_impl( inline SPROUT_CONSTEXPR ForwardIterator next_impl(
ForwardIterator it, ForwardIterator const& it,
typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::difference_type n, typename std::iterator_traits<ForwardIterator>::difference_type n,
void* void*
) )
{ {
return std::next(sprout::forward<ForwardIterator>(it), n); return std::next(it, n);
} }
} // namespace detail
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
iterator_next(ForwardIterator const& it) {
typedef typename std::iterator_traits<ForwardIterator>::iterator_category* category;
return sprout::iterator_detail::next_impl(it, category());
}
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
iterator_next(ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n) {
typedef typename std::iterator_traits<ForwardIterator>::iterator_category* category;
return sprout::iterator_detail::next_impl(it, n, category());
}
} // namespace iterator_detail
} // namespace sprout
namespace sprout_iterator_detail {
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
next(ForwardIterator const& it) {
using sprout::iterator_detail::iterator_next;
return iterator_next(it);
}
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
next(ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n) {
using sprout::iterator_detail::iterator_next;
return iterator_next(it, n);
}
} // namespace sprout_iterator_detail
namespace sprout {
// //
// next // next
// //
template<typename ForwardIterator> template<typename ForwardIterator>
inline SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type inline SPROUT_CONSTEXPR ForwardIterator
next(ForwardIterator&& it) { next(ForwardIterator const& it) {
typedef typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::iterator_category* category; return sprout_iterator_detail::next(it);
return sprout::detail::next_impl(
sprout::forward<ForwardIterator>(it),
category()
);
} }
template<typename ForwardIterator> template<typename ForwardIterator>
inline SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type inline SPROUT_CONSTEXPR ForwardIterator
next(ForwardIterator&& it, typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::difference_type n) { next(ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n) {
typedef typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::iterator_category* category; return sprout_iterator_detail::next(it, n);
return sprout::detail::next_impl(
sprout::forward<ForwardIterator>(it),
n,
category()
);
} }
} // namespace sprout } // namespace sprout

View file

@ -4,73 +4,94 @@
#include <iterator> #include <iterator>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
namespace detail { namespace iterator_detail {
template<typename RandomAccessIterator> template<typename RandomAccessIterator>
inline SPROUT_CONSTEXPR typename std::enable_if< inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value, std::is_literal_type<RandomAccessIterator>::value,
typename std::decay<RandomAccessIterator>::type RandomAccessIterator
>::type prev_impl( >::type prev_impl(
RandomAccessIterator&& it, RandomAccessIterator const& it,
std::random_access_iterator_tag* std::random_access_iterator_tag*
) )
{ {
return sprout::forward<RandomAccessIterator>(it) - 1; return it - 1;
} }
template<typename BidirectionalIterator> template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR typename std::decay<BidirectionalIterator>::type prev_impl( inline SPROUT_CONSTEXPR BidirectionalIterator prev_impl(
BidirectionalIterator&& it, BidirectionalIterator const& it,
void* void*
) )
{ {
return std::prev(sprout::forward<BidirectionalIterator>(it)); return std::prev(it);
} }
template<typename RandomAccessIterator> template<typename RandomAccessIterator>
inline SPROUT_CONSTEXPR typename std::enable_if< inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value, std::is_literal_type<RandomAccessIterator>::value,
typename std::decay<RandomAccessIterator>::type RandomAccessIterator
>::type prev_impl( >::type prev_impl(
RandomAccessIterator&& it, RandomAccessIterator const& it,
typename std::iterator_traits<typename std::decay<RandomAccessIterator>::type>::difference_type n, typename std::iterator_traits<RandomAccessIterator>::difference_type n,
std::random_access_iterator_tag* std::random_access_iterator_tag*
) )
{ {
return sprout::forward<RandomAccessIterator>(it) - n; return it - n;
} }
template<typename BidirectionalIterator> template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR typename std::decay<BidirectionalIterator>::type prev_impl( inline SPROUT_CONSTEXPR BidirectionalIterator prev_impl(
BidirectionalIterator it, BidirectionalIterator const& it,
typename std::iterator_traits<typename std::decay<BidirectionalIterator>::type>::difference_type n, typename std::iterator_traits<BidirectionalIterator>::difference_type n,
void* void*
) )
{ {
return std::prev(sprout::forward<BidirectionalIterator>(it), n); return std::prev(it, n);
} }
} // namespace detail
template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR BidirectionalIterator
iterator_prev(BidirectionalIterator const& it) {
typedef typename std::iterator_traits<BidirectionalIterator>::iterator_category* category;
return sprout::iterator_detail::prev_impl(it, category());
}
template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR BidirectionalIterator
iterator_prev(BidirectionalIterator const& it, typename std::iterator_traits<BidirectionalIterator>::difference_type n) {
typedef typename std::iterator_traits<BidirectionalIterator>::iterator_category* category;
return sprout::iterator_detail::prev_impl(it, n, category());
}
} // namespace iterator_detail
} // namespace sprout
namespace sprout_iterator_detail {
template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR BidirectionalIterator
prev(BidirectionalIterator const& it) {
using sprout::iterator_detail::iterator_prev;
return iterator_prev(it);
}
template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR BidirectionalIterator
prev(BidirectionalIterator const& it, typename std::iterator_traits<BidirectionalIterator>::difference_type n) {
using sprout::iterator_detail::iterator_prev;
return iterator_prev(it, n);
}
} // namespace sprout_iterator_detail
namespace sprout {
// //
// prev // prev
// //
template<typename BidirectionalIterator> template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR typename std::decay<BidirectionalIterator>::type inline SPROUT_CONSTEXPR BidirectionalIterator
prev(BidirectionalIterator&& it) { prev(BidirectionalIterator const& it) {
typedef typename std::iterator_traits<typename std::decay<BidirectionalIterator>::type>::iterator_category* category; return sprout_iterator_detail::prev(it);
return sprout::detail::prev_impl(
sprout::forward<BidirectionalIterator>(it),
category()
);
} }
template<typename BidirectionalIterator> template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR typename std::decay<BidirectionalIterator>::type inline SPROUT_CONSTEXPR BidirectionalIterator
prev(BidirectionalIterator&& it, typename std::iterator_traits<typename std::decay<BidirectionalIterator>::type>::difference_type n) { prev(BidirectionalIterator const& it, typename std::iterator_traits<BidirectionalIterator>::difference_type n) {
typedef typename std::iterator_traits<typename std::decay<BidirectionalIterator>::type>::iterator_category* category; return sprout_iterator_detail::prev(it, n);
return sprout::detail::prev_impl(
sprout::forward<BidirectionalIterator>(it),
n,
category()
);
} }
} // namespace sprout } // namespace sprout

View file

@ -199,44 +199,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::reverse_iterator<Iterator> next(
sprout::reverse_iterator<Iterator> const& it
)
{
return it.next();
}
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::reverse_iterator<Iterator> next(
sprout::reverse_iterator<Iterator> const& it,
typename sprout::reverse_iterator<Iterator>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::reverse_iterator<Iterator> prev(
sprout::reverse_iterator<Iterator> const& it
)
{
return it.prev();
}
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::reverse_iterator<Iterator> prev(
sprout::reverse_iterator<Iterator> const& it,
typename sprout::reverse_iterator<Iterator>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -249,6 +211,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::reverse_iterator<Iterator> iterator_next(
sprout::reverse_iterator<Iterator> const& it
)
{
return it.next();
}
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::reverse_iterator<Iterator> iterator_next(
sprout::reverse_iterator<Iterator> const& it,
typename sprout::reverse_iterator<Iterator>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::reverse_iterator<Iterator> iterator_prev(
sprout::reverse_iterator<Iterator> const& it
)
{
return it.prev();
}
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::reverse_iterator<Iterator> iterator_prev(
sprout::reverse_iterator<Iterator> const& it,
typename sprout::reverse_iterator<Iterator>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_REVERSE_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_REVERSE_ITERATOR_HPP

View file

@ -218,44 +218,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> next(
sprout::sawtooth_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> next(
sprout::sawtooth_iterator<Value> const& it,
typename sprout::sawtooth_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> prev(
sprout::sawtooth_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> prev(
sprout::sawtooth_iterator<Value> const& it,
typename sprout::sawtooth_iterator<Value>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -268,6 +230,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> iterator_next(
sprout::sawtooth_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> iterator_next(
sprout::sawtooth_iterator<Value> const& it,
typename sprout::sawtooth_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> iterator_prev(
sprout::sawtooth_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> iterator_prev(
sprout::sawtooth_iterator<Value> const& it,
typename sprout::sawtooth_iterator<Value>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_SAWTOOTH_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_SAWTOOTH_ITERATOR_HPP

View file

@ -227,44 +227,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sinusoid_iterator<Value> next(
sprout::sinusoid_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sinusoid_iterator<Value> next(
sprout::sinusoid_iterator<Value> const& it,
typename sprout::sinusoid_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sinusoid_iterator<Value> prev(
sprout::sinusoid_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sinusoid_iterator<Value> prev(
sprout::sinusoid_iterator<Value> const& it,
typename sprout::sinusoid_iterator<Value>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -277,6 +239,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sinusoid_iterator<Value> iterator_next(
sprout::sinusoid_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sinusoid_iterator<Value> iterator_next(
sprout::sinusoid_iterator<Value> const& it,
typename sprout::sinusoid_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sinusoid_iterator<Value> iterator_prev(
sprout::sinusoid_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::sinusoid_iterator<Value> iterator_prev(
sprout::sinusoid_iterator<Value> const& it,
typename sprout::sinusoid_iterator<Value>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_SINUSOID_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_SINUSOID_ITERATOR_HPP

View file

@ -392,44 +392,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename Iterator, bool Separated>
inline SPROUT_CONSTEXPR sprout::size_enum_iterator<Iterator, Separated> next(
sprout::size_enum_iterator<Iterator, Separated> const& it
)
{
return it.next();
}
template<typename Iterator, bool Separated>
inline SPROUT_CONSTEXPR sprout::size_enum_iterator<Iterator, Separated> next(
sprout::size_enum_iterator<Iterator, Separated> const& it,
typename sprout::size_enum_iterator<Iterator, Separated>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Iterator, bool Separated>
inline SPROUT_CONSTEXPR sprout::size_enum_iterator<Iterator, Separated> prev(
sprout::size_enum_iterator<Iterator, Separated> const& it
)
{
return it.prev();
}
template<typename Iterator, bool Separated>
inline SPROUT_CONSTEXPR sprout::size_enum_iterator<Iterator, Separated> prev(
sprout::size_enum_iterator<Iterator, Separated> const& it,
typename sprout::size_enum_iterator<Iterator, Separated>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -442,6 +404,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename Iterator, bool Separated>
inline SPROUT_CONSTEXPR sprout::size_enum_iterator<Iterator, Separated> iterator_next(
sprout::size_enum_iterator<Iterator, Separated> const& it
)
{
return it.next();
}
template<typename Iterator, bool Separated>
inline SPROUT_CONSTEXPR sprout::size_enum_iterator<Iterator, Separated> iterator_next(
sprout::size_enum_iterator<Iterator, Separated> const& it,
typename sprout::size_enum_iterator<Iterator, Separated>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Iterator, bool Separated>
inline SPROUT_CONSTEXPR sprout::size_enum_iterator<Iterator, Separated> iterator_prev(
sprout::size_enum_iterator<Iterator, Separated> const& it
)
{
return it.prev();
}
template<typename Iterator, bool Separated>
inline SPROUT_CONSTEXPR sprout::size_enum_iterator<Iterator, Separated> iterator_prev(
sprout::size_enum_iterator<Iterator, Separated> const& it,
typename sprout::size_enum_iterator<Iterator, Separated>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_SIZE_ENUM_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_SIZE_ENUM_ITERATOR_HPP

View file

@ -228,44 +228,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::square_iterator<Value> next(
sprout::square_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::square_iterator<Value> next(
sprout::square_iterator<Value> const& it,
typename sprout::square_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::square_iterator<Value> prev(
sprout::square_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::square_iterator<Value> prev(
sprout::square_iterator<Value> const& it,
typename sprout::square_iterator<Value>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -278,6 +240,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::square_iterator<Value> iterator_next(
sprout::square_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::square_iterator<Value> iterator_next(
sprout::square_iterator<Value> const& it,
typename sprout::square_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::square_iterator<Value> iterator_prev(
sprout::square_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::square_iterator<Value> iterator_prev(
sprout::square_iterator<Value> const& it,
typename sprout::square_iterator<Value>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_SQUARE_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_SQUARE_ITERATOR_HPP

View file

@ -386,44 +386,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename UnaryOrBinaryFunction, typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> next(
sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> const& it
)
{
return it.next();
}
template<typename UnaryOrBinaryFunction, typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> next(
sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> const& it,
typename sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename UnaryOrBinaryFunction, typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> prev(
sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> const& it
)
{
return it.prev();
}
template<typename UnaryOrBinaryFunction, typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> prev(
sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> const& it,
typename sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -436,6 +398,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename UnaryOrBinaryFunction, typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> iterator_next(
sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> const& it
)
{
return it.next();
}
template<typename UnaryOrBinaryFunction, typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> iterator_next(
sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> const& it,
typename sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename UnaryOrBinaryFunction, typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> iterator_prev(
sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> const& it
)
{
return it.prev();
}
template<typename UnaryOrBinaryFunction, typename LIterator, typename RIterator>
inline SPROUT_CONSTEXPR sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> iterator_prev(
sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator> const& it,
typename sprout::transform_iterator<UnaryOrBinaryFunction, LIterator, RIterator>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TRANSFORM_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_TRANSFORM_ITERATOR_HPP

View file

@ -218,44 +218,6 @@ namespace sprout {
lhs.swap(rhs); lhs.swap(rhs);
} }
//
// next
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::triangle_iterator<Value> next(
sprout::triangle_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::triangle_iterator<Value> next(
sprout::triangle_iterator<Value> const& it,
typename sprout::triangle_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::triangle_iterator<Value> prev(
sprout::triangle_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::triangle_iterator<Value> prev(
sprout::triangle_iterator<Value> const& it,
typename sprout::triangle_iterator<Value>::difference_type n
)
{
return it - n;
}
// //
// distance // distance
// //
@ -268,6 +230,44 @@ namespace sprout {
{ {
return last - first; return last - first;
} }
//
// iterator_next
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::triangle_iterator<Value> iterator_next(
sprout::triangle_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::triangle_iterator<Value> iterator_next(
sprout::triangle_iterator<Value> const& it,
typename sprout::triangle_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// iterator_prev
//
template<typename Value>
inline SPROUT_CONSTEXPR sprout::triangle_iterator<Value> iterator_prev(
sprout::triangle_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
inline SPROUT_CONSTEXPR sprout::triangle_iterator<Value> iterator_prev(
sprout::triangle_iterator<Value> const& it,
typename sprout::triangle_iterator<Value>::difference_type n
)
{
return it - n;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TRIANGLE_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_TRIANGLE_ITERATOR_HPP

View file

@ -165,17 +165,26 @@ namespace sprout {
} }
// //
// next // distance
// //
template<typename T> template<typename T>
inline SPROUT_CONSTEXPR sprout::value_iterator<T> next( inline SPROUT_CONSTEXPR typename std::iterator_traits<sprout::value_iterator<T> >::difference_type
distance(sprout::value_iterator<T> first, sprout::value_iterator<T> last) {
return last - first;
}
//
// iterator_next
//
template<typename T>
inline SPROUT_CONSTEXPR sprout::value_iterator<T> iterator_next(
sprout::value_iterator<T> const& it sprout::value_iterator<T> const& it
) )
{ {
return it.next(); return it.next();
} }
template<typename T> template<typename T>
inline SPROUT_CONSTEXPR sprout::value_iterator<T> next( inline SPROUT_CONSTEXPR sprout::value_iterator<T> iterator_next(
sprout::value_iterator<T> const& it, sprout::value_iterator<T> const& it,
typename sprout::value_iterator<T>::difference_type n typename sprout::value_iterator<T>::difference_type n
) )
@ -184,32 +193,23 @@ namespace sprout {
} }
// //
// prev // iterator_prev
// //
template<typename T> template<typename T>
inline SPROUT_CONSTEXPR sprout::value_iterator<T> prev( inline SPROUT_CONSTEXPR sprout::value_iterator<T> iterator_prev(
sprout::value_iterator<T> const& it sprout::value_iterator<T> const& it
) )
{ {
return it.prev(); return it.prev();
} }
template<typename T> template<typename T>
inline SPROUT_CONSTEXPR sprout::value_iterator<T> prev( inline SPROUT_CONSTEXPR sprout::value_iterator<T> iterator_prev(
sprout::value_iterator<T> const& it, sprout::value_iterator<T> const& it,
typename sprout::value_iterator<T>::difference_type n typename sprout::value_iterator<T>::difference_type n
) )
{ {
return it - n; return it - n;
} }
//
// distance
//
template<typename T>
inline SPROUT_CONSTEXPR typename std::iterator_traits<sprout::value_iterator<T> >::difference_type
distance(sprout::value_iterator<T> first, sprout::value_iterator<T> last) {
return last - first;
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_VALUE_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_VALUE_ITERATOR_HPP

View file

@ -306,10 +306,10 @@ namespace sprout {
} }
// //
// next // iterator_next
// //
template<typename Engine, typename Distribution> template<typename Engine, typename Distribution>
SPROUT_CONSTEXPR sprout::random::random_iterator<Engine, Distribution> next( SPROUT_CONSTEXPR sprout::random::random_iterator<Engine, Distribution> iterator_next(
sprout::random::random_iterator<Engine, Distribution> const& it sprout::random::random_iterator<Engine, Distribution> const& it
) )
{ {

View file

@ -230,6 +230,7 @@ namespace sprout {
return result; return result;
} }
}; };
// //
// swap // swap
// //
@ -241,18 +242,18 @@ namespace sprout {
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
} // namespace random
// //
// next // next
// //
template<typename Engine, typename Distribution> template<typename Engine, typename Distribution>
SPROUT_CONSTEXPR sprout::random::random_result<Engine, Distribution> next( SPROUT_CONSTEXPR sprout::random::random_result<Engine, Distribution> next(
sprout::random::random_result<Engine, Distribution> const& it sprout::random::random_result<Engine, Distribution> const& it
) )
{ {
return it(); return it();
} }
} // namespace random
using sprout::random::random_result; using sprout::random::random_result;
} // namespace sprout } // namespace sprout

View file

@ -91,26 +91,19 @@ namespace sprout {
} // namespace sprout } // namespace sprout
namespace sprout_tuple_detail { namespace sprout_tuple_detail {
struct not_found_adl_get {};
template<std::size_t I>
sprout_tuple_detail::not_found_adl_get get(...);
template<std::size_t I, typename T> template<std::size_t I, typename T>
struct has_adl_get_test { struct has_spr_get_test {
public: public:
template< template<
typename U = T, typename U = T,
typename sprout::enabler_if< typename = decltype(sprout::tuples::get<I>(std::declval<U>()))
!std::is_same<decltype(get<I>(std::declval<U>())), sprout_tuple_detail::not_found_adl_get>::value
>::type = sprout::enabler
> >
static std::true_type test(int); static std::true_type test(int);
static std::false_type test(...); static std::false_type test(...);
}; };
template<std::size_t I, typename T> template<std::size_t I, typename T>
struct has_adl_get struct has_spr_get
: public decltype(sprout_tuple_detail::has_adl_get_test<I, T>::test(0)) : public decltype(sprout_tuple_detail::has_spr_get_test<I, T>::test(0))
{}; {};
template<std::size_t I, typename T> template<std::size_t I, typename T>
@ -129,18 +122,18 @@ namespace sprout_tuple_detail {
{}; {};
template<std::size_t I, typename T, typename Enable = void> template<std::size_t I, typename T, typename Enable = void>
struct select_adl_get; struct select_spr_get;
template<std::size_t I, typename T> template<std::size_t I, typename T>
struct select_adl_get< struct select_spr_get<
I, T, I, T,
typename std::enable_if<sprout_tuple_detail::has_adl_get<I, T>::value>::type typename std::enable_if<sprout_tuple_detail::has_spr_get<I, T>::value>::type
> >
: public std::true_type : public std::true_type
{}; {};
template<std::size_t I, typename T> template<std::size_t I, typename T>
struct select_adl_get< struct select_spr_get<
I, T, I, T,
typename std::enable_if<!sprout_tuple_detail::has_adl_get<I, T>::value>::type typename std::enable_if<!sprout_tuple_detail::has_spr_get<I, T>::value>::type
> >
: public std::false_type : public std::false_type
{}; {};
@ -152,7 +145,7 @@ namespace sprout_tuple_detail {
I, T, I, T,
typename std::enable_if< typename std::enable_if<
sprout_tuple_detail::has_std_get<I, T>::value sprout_tuple_detail::has_std_get<I, T>::value
&& !sprout_tuple_detail::has_adl_get<I, T>::value && !sprout_tuple_detail::has_spr_get<I, T>::value
>::type >::type
> >
: public std::true_type : public std::true_type
@ -162,7 +155,7 @@ namespace sprout_tuple_detail {
I, T, I, T,
typename std::enable_if<!( typename std::enable_if<!(
sprout_tuple_detail::has_std_get<I, T>::value sprout_tuple_detail::has_std_get<I, T>::value
&& !sprout_tuple_detail::has_adl_get<I, T>::value && !sprout_tuple_detail::has_spr_get<I, T>::value
)>::type )>::type
> >
: public std::false_type : public std::false_type
@ -170,10 +163,10 @@ namespace sprout_tuple_detail {
template<std::size_t I, typename T, typename = void> template<std::size_t I, typename T, typename = void>
struct noexcept_get; struct noexcept_get;
template<std::size_t I, typename T> // template<std::size_t I, typename T>
struct noexcept_get<I, T, typename std::enable_if<sprout_tuple_detail::select_adl_get<I, T>::value>::type> // struct noexcept_get<I, T, typename std::enable_if<sprout_tuple_detail::select_spr_get<I, T>::value>::type>
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(get<I>(std::declval<T>()), false)> // : public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(sprout::tuples::get<I>(std::declval<T>()), false)>
{}; // {};
template<std::size_t I, typename T> template<std::size_t I, typename T>
struct noexcept_get<I, T, typename std::enable_if<sprout_tuple_detail::select_std_get<I, T>::value>::type> struct noexcept_get<I, T, typename std::enable_if<sprout_tuple_detail::select_std_get<I, T>::value>::type>
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::get<I>(std::declval<T>()), false)> : public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::get<I>(std::declval<T>()), false)>
@ -181,27 +174,27 @@ namespace sprout_tuple_detail {
template<std::size_t I, typename T, typename = void> template<std::size_t I, typename T, typename = void>
struct get_result; struct get_result;
template<std::size_t I, typename T> // template<std::size_t I, typename T>
struct get_result<I, T, typename std::enable_if<sprout_tuple_detail::select_adl_get<I, T>::value>::type> { // struct get_result<I, T, typename std::enable_if<sprout_tuple_detail::select_spr_get<I, T>::value>::type> {
public: // public:
typedef decltype(get<I>(std::declval<T>())) type; // typedef decltype(sprout::tuples::get<I>(std::declval<T>())) type;
}; // };
template<std::size_t I, typename T> template<std::size_t I, typename T>
struct get_result<I, T, typename std::enable_if<sprout_tuple_detail::select_std_get<I, T>::value>::type> { struct get_result<I, T, typename std::enable_if<sprout_tuple_detail::select_std_get<I, T>::value>::type> {
public: public:
typedef decltype(std::get<I>(std::declval<T>())) type; typedef decltype(std::get<I>(std::declval<T>())) type;
}; };
template< // template<
std::size_t I, typename T, // std::size_t I, typename T,
typename sprout::enabler_if<sprout_tuple_detail::select_adl_get<I, T>::value>::type = sprout::enabler // typename sprout::enabler_if<sprout_tuple_detail::select_spr_get<I, T>::value>::type = sprout::enabler
> // >
inline SPROUT_CONSTEXPR typename sprout_tuple_detail::get_result<I, T>::type // inline SPROUT_CONSTEXPR typename sprout_tuple_detail::get_result<I, T>::type
get_impl(T&& t) // get_impl(T&& t)
SPROUT_NOEXCEPT_EXPR((sprout_tuple_detail::noexcept_get<I, T>::value)) // SPROUT_NOEXCEPT_EXPR((sprout_tuple_detail::noexcept_get<I, T>::value))
{ // {
return get<I>(sprout::forward<T>(t)); // return sprout::tuples::get<I>(sprout::forward<T>(t));
} // }
template< template<
std::size_t I, typename T, std::size_t I, typename T,
typename sprout::enabler_if<sprout_tuple_detail::select_std_get<I, T>::value>::type = sprout::enabler typename sprout::enabler_if<sprout_tuple_detail::select_std_get<I, T>::value>::type = sprout::enabler