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/tuple/tuple/get.hpp>
namespace sprout_generator_detail {
struct not_found_adl_generated_value {};
namespace sprout {
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>
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))
{};
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>
struct has_tuple_get_generated_value_test {
public:
template<
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::false_type test(...);
@ -60,40 +62,40 @@ namespace sprout_generator_detail {
{};
template<typename T, typename Enable = void>
struct select_mem_generated_value;
struct select_spr_generated_value;
template<typename T>
struct select_mem_generated_value<
struct select_spr_generated_value<
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
{};
template<typename T>
struct select_mem_generated_value<
struct select_spr_generated_value<
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
{};
template<typename T, typename Enable = void>
struct select_adl_generated_value;
struct select_mem_generated_value;
template<typename T>
struct select_adl_generated_value<
struct select_mem_generated_value<
T,
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
>
: public std::true_type
{};
template<typename T>
struct select_adl_generated_value<
struct select_mem_generated_value<
T,
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
>
: public std::false_type
@ -106,8 +108,8 @@ namespace sprout_generator_detail {
T,
typename std::enable_if<
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_adl_generated_value<T>::value
>::type
>
: public std::true_type
@ -117,8 +119,8 @@ namespace sprout_generator_detail {
T,
typename std::enable_if<!(
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_adl_generated_value<T>::value
)>::type
>
: public std::false_type
@ -126,37 +128,47 @@ namespace sprout_generator_detail {
template<typename T, typename = void>
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>
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)>
{};
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>
: 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>
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>
struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type> {
public:
typedef decltype(std::declval<T>().generated_value()) type;
};
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> {
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<
typename T,
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();
}
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<
typename T,
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)
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

View file

@ -7,10 +7,29 @@
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/tuple/tuple/get.hpp>
namespace sprout_generator_detail {
struct not_found_adl_next_generator {};
namespace sprout {
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>
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))
{};
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>
struct has_tuple_get_next_generator_test {
public:
template<
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::false_type test(...);
@ -60,40 +62,40 @@ namespace sprout_generator_detail {
{};
template<typename T, typename Enable = void>
struct select_mem_next_generator;
struct select_spr_next_generator;
template<typename T>
struct select_mem_next_generator<
struct select_spr_next_generator<
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
{};
template<typename T>
struct select_mem_next_generator<
struct select_spr_next_generator<
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
{};
template<typename T, typename Enable = void>
struct select_adl_next_generator;
struct select_mem_next_generator;
template<typename T>
struct select_adl_next_generator<
struct select_mem_next_generator<
T,
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
>
: public std::true_type
{};
template<typename T>
struct select_adl_next_generator<
struct select_mem_next_generator<
T,
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
>
: public std::false_type
@ -106,8 +108,8 @@ namespace sprout_generator_detail {
T,
typename std::enable_if<
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_adl_next_generator<T>::value
>::type
>
: public std::true_type
@ -117,8 +119,8 @@ namespace sprout_generator_detail {
T,
typename std::enable_if<!(
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_adl_next_generator<T>::value
)>::type
>
: public std::false_type
@ -126,37 +128,47 @@ namespace sprout_generator_detail {
template<typename T, typename = void>
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>
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)>
{};
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>
: 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>
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>
struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type> {
public:
typedef decltype(std::declval<T>().next_generator()) type;
};
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> {
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<
typename T,
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();
}
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<
typename T,
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)
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

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
//
@ -170,44 +182,6 @@ namespace sprout {
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
//
@ -222,15 +196,41 @@ namespace sprout {
}
//
// make_bytes_iterator
// iterator_next
//
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> iterator_next(
sprout::bytes_iterator<Iterator, Traits> const& it
)
{
return it.next();
}
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);
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits> iterator_next(
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

View file

@ -190,44 +190,6 @@ namespace sprout {
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
//
@ -240,6 +202,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP

View file

@ -129,10 +129,10 @@ namespace sprout {
return temp;
}
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 {
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) {
using std::swap;
@ -177,10 +177,10 @@ namespace sprout {
}
//
// next
// iterator_next
//
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
)
{
@ -188,10 +188,10 @@ namespace sprout {
}
//
// prev
// iterator_prev
//
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
)
{

View file

@ -195,44 +195,6 @@ namespace sprout {
: 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
//
@ -245,6 +207,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_INDEX_ITERATOR_HPP

View file

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

View file

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

View file

@ -199,44 +199,6 @@ namespace sprout {
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
//
@ -249,6 +211,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_REVERSE_ITERATOR_HPP

View file

@ -218,44 +218,6 @@ namespace sprout {
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
//
@ -268,6 +230,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_SAWTOOTH_ITERATOR_HPP

View file

@ -227,44 +227,6 @@ namespace sprout {
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
//
@ -277,6 +239,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_SINUSOID_ITERATOR_HPP

View file

@ -392,44 +392,6 @@ namespace sprout {
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
//
@ -442,6 +404,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_SIZE_ENUM_ITERATOR_HPP

View file

@ -228,44 +228,6 @@ namespace sprout {
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
//
@ -278,6 +240,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_SQUARE_ITERATOR_HPP

View file

@ -386,44 +386,6 @@ namespace sprout {
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
//
@ -436,6 +398,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_TRANSFORM_ITERATOR_HPP

View file

@ -218,44 +218,6 @@ namespace sprout {
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
//
@ -268,6 +230,44 @@ namespace sprout {
{
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
#endif // #ifndef SPROUT_ITERATOR_TRIANGLE_ITERATOR_HPP

View file

@ -165,17 +165,26 @@ namespace sprout {
}
//
// next
// distance
//
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
)
{
return it.next();
}
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,
typename sprout::value_iterator<T>::difference_type n
)
@ -184,32 +193,23 @@ namespace sprout {
}
//
// prev
// iterator_prev
//
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
)
{
return it.prev();
}
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,
typename sprout::value_iterator<T>::difference_type 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
#endif // #ifndef SPROUT_ITERATOR_VALUE_ITERATOR_HPP

View file

@ -306,10 +306,10 @@ namespace sprout {
}
//
// next
// iterator_next
//
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
)
{

View file

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

View file

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