diff --git a/sprout/generator/generated_value.hpp b/sprout/generator/generated_value.hpp index cfb82086..fe535ea3 100644 --- a/sprout/generator/generated_value.hpp +++ b/sprout/generator/generated_value.hpp @@ -7,10 +7,29 @@ #include #include -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 + struct has_spr_generated_value_test { + public: + template< + typename U = T, + typename = decltype(sprout::generators::generated_value(std::declval())) + > + static std::true_type test(int); + static std::false_type test(...); + }; + template + struct has_spr_generated_value + : public decltype(sprout_generator_detail::has_spr_generated_value_test::test(0)) + {}; template struct has_mem_generated_value_test { @@ -27,29 +46,12 @@ namespace sprout_generator_detail { : public decltype(sprout_generator_detail::has_mem_generated_value_test::test(0)) {}; - template - struct has_adl_generated_value_test { - public: - template< - typename U = T, - typename sprout::enabler_if< - !std::is_same())), sprout_generator_detail::not_found_adl_generated_value>::value - >::type = sprout::enabler - > - static std::true_type test(int); - static std::false_type test(...); - }; - template - struct has_adl_generated_value - : public decltype(sprout_generator_detail::has_adl_generated_value_test::test(0)) - {}; - template struct has_tuple_get_generated_value_test { public: template< typename U = T, - typename = decltype(sprout::tuples::get<0>(std::declval())) + typename = decltype(get<0>(std::declval())) > static std::true_type test(int); static std::false_type test(...); @@ -60,40 +62,40 @@ namespace sprout_generator_detail { {}; template - struct select_mem_generated_value; + struct select_spr_generated_value; template - struct select_mem_generated_value< + struct select_spr_generated_value< T, - typename std::enable_if::value>::type + typename std::enable_if::value>::type > : public std::true_type {}; template - struct select_mem_generated_value< + struct select_spr_generated_value< T, - typename std::enable_if::value>::type + typename std::enable_if::value>::type > : public std::false_type {}; template - struct select_adl_generated_value; + struct select_mem_generated_value; template - struct select_adl_generated_value< + struct select_mem_generated_value< T, typename std::enable_if< - sprout_generator_detail::has_adl_generated_value::value - && !sprout_generator_detail::has_mem_generated_value::value + sprout_generator_detail::has_mem_generated_value::value + && !sprout_generator_detail::has_spr_generated_value::value >::type > : public std::true_type {}; template - struct select_adl_generated_value< + struct select_mem_generated_value< T, typename std::enable_if::value - && !sprout_generator_detail::has_mem_generated_value::value + sprout_generator_detail::has_mem_generated_value::value + && !sprout_generator_detail::has_spr_generated_value::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::value + && !sprout_generator_detail::has_spr_generated_value::value && !sprout_generator_detail::has_mem_generated_value::value - && !sprout_generator_detail::has_adl_generated_value::value >::type > : public std::true_type @@ -117,8 +119,8 @@ namespace sprout_generator_detail { T, typename std::enable_if::value + && !sprout_generator_detail::has_spr_generated_value::value && !sprout_generator_detail::has_mem_generated_value::value - && !sprout_generator_detail::has_adl_generated_value::value )>::type > : public std::false_type @@ -126,37 +128,47 @@ namespace sprout_generator_detail { template struct noexcept_generated_value; +// template +// struct noexcept_generated_value::value>::type> +// : public std::integral_constant()), false)> +// {}; template struct noexcept_generated_value::value>::type> : public std::integral_constant().generated_value(), false)> {}; template - struct noexcept_generated_value::value>::type> - : public std::integral_constant()), false)> - {}; - template struct noexcept_generated_value::value>::type> - : public std::integral_constant(std::declval()), false)> + : public std::integral_constant(std::declval()), false)> {}; template struct generated_value_result; +// template +// struct generated_value_result::value>::type> { +// public: +// typedef decltype(sprout::generators::generated_value(std::declval())) type; +// }; template struct generated_value_result::value>::type> { public: typedef decltype(std::declval().generated_value()) type; }; template - struct generated_value_result::value>::type> { - public: - typedef decltype(generated_value(std::declval())) type; - }; - template struct generated_value_result::value>::type> { public: - typedef decltype(sprout::tuples::get<0>(std::declval())) type; + typedef decltype(get<0>(std::declval())) type; }; +// template< +// typename T, +// typename sprout::enabler_if::value>::type = sprout::enabler +// > +// inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result::type +// generated_value_impl(T&& t) +// SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value::value)) +// { +// return sprout::generators::generated_value(sprout::forward(t)); +// } template< typename T, typename sprout::enabler_if::value>::type = sprout::enabler @@ -167,16 +179,6 @@ namespace sprout_generator_detail { { return sprout::forward(t).generated_value(); } - template< - typename T, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result::type - generated_value_impl(T&& t) - SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value::value)) - { - return generated_value(sprout::forward(t)); - } template< typename T, typename sprout::enabler_if::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::value)) { - return sprout::tuples::get<0>(sprout::forward(t)); + return get<0>(sprout::forward(t)); } } // namespace sprout_generator_detail diff --git a/sprout/generator/next_generator.hpp b/sprout/generator/next_generator.hpp index fcefd395..d7fd733a 100644 --- a/sprout/generator/next_generator.hpp +++ b/sprout/generator/next_generator.hpp @@ -7,10 +7,29 @@ #include #include -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 + struct has_spr_next_generator_test { + public: + template< + typename U = T, + typename = decltype(sprout::generators::next_generator(std::declval())) + > + static std::true_type test(int); + static std::false_type test(...); + }; + template + struct has_spr_next_generator + : public decltype(sprout_generator_detail::has_spr_next_generator_test::test(0)) + {}; template struct has_mem_next_generator_test { @@ -27,29 +46,12 @@ namespace sprout_generator_detail { : public decltype(sprout_generator_detail::has_mem_next_generator_test::test(0)) {}; - template - struct has_adl_next_generator_test { - public: - template< - typename U = T, - typename sprout::enabler_if< - !std::is_same())), sprout_generator_detail::not_found_adl_next_generator>::value - >::type = sprout::enabler - > - static std::true_type test(int); - static std::false_type test(...); - }; - template - struct has_adl_next_generator - : public decltype(sprout_generator_detail::has_adl_next_generator_test::test(0)) - {}; - template struct has_tuple_get_next_generator_test { public: template< typename U = T, - typename = decltype(sprout::tuples::get<1>(std::declval())) + typename = decltype(get<1>(std::declval())) > static std::true_type test(int); static std::false_type test(...); @@ -60,40 +62,40 @@ namespace sprout_generator_detail { {}; template - struct select_mem_next_generator; + struct select_spr_next_generator; template - struct select_mem_next_generator< + struct select_spr_next_generator< T, - typename std::enable_if::value>::type + typename std::enable_if::value>::type > : public std::true_type {}; template - struct select_mem_next_generator< + struct select_spr_next_generator< T, - typename std::enable_if::value>::type + typename std::enable_if::value>::type > : public std::false_type {}; template - struct select_adl_next_generator; + struct select_mem_next_generator; template - struct select_adl_next_generator< + struct select_mem_next_generator< T, typename std::enable_if< - sprout_generator_detail::has_adl_next_generator::value - && !sprout_generator_detail::has_mem_next_generator::value + sprout_generator_detail::has_mem_next_generator::value + && !sprout_generator_detail::has_spr_next_generator::value >::type > : public std::true_type {}; template - struct select_adl_next_generator< + struct select_mem_next_generator< T, typename std::enable_if::value - && !sprout_generator_detail::has_mem_next_generator::value + sprout_generator_detail::has_mem_next_generator::value + && !sprout_generator_detail::has_spr_next_generator::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::value + && !sprout_generator_detail::has_spr_next_generator::value && !sprout_generator_detail::has_mem_next_generator::value - && !sprout_generator_detail::has_adl_next_generator::value >::type > : public std::true_type @@ -117,8 +119,8 @@ namespace sprout_generator_detail { T, typename std::enable_if::value + && !sprout_generator_detail::has_spr_next_generator::value && !sprout_generator_detail::has_mem_next_generator::value - && !sprout_generator_detail::has_adl_next_generator::value )>::type > : public std::false_type @@ -126,37 +128,47 @@ namespace sprout_generator_detail { template struct noexcept_next_generator; +// template +// struct noexcept_next_generator::value>::type> +// : public std::integral_constant()), false)> +// {}; template struct noexcept_next_generator::value>::type> : public std::integral_constant().next_generator(), false)> {}; template - struct noexcept_next_generator::value>::type> - : public std::integral_constant()), false)> - {}; - template struct noexcept_next_generator::value>::type> - : public std::integral_constant(std::declval()), false)> + : public std::integral_constant(std::declval()), false)> {}; template struct next_generator_result; +// template +// struct next_generator_result::value>::type> { +// public: +// typedef decltype(sprout::generators::next_generator(std::declval())) type; +// }; template struct next_generator_result::value>::type> { public: typedef decltype(std::declval().next_generator()) type; }; template - struct next_generator_result::value>::type> { - public: - typedef decltype(next_generator(std::declval())) type; - }; - template struct next_generator_result::value>::type> { public: - typedef decltype(sprout::tuples::get<1>(std::declval())) type; + typedef decltype(get<1>(std::declval())) type; }; +// template< +// typename T, +// typename sprout::enabler_if::value>::type = sprout::enabler +// > +// inline SPROUT_CONSTEXPR typename sprout_generator_detail::next_generator_result::type +// next_generator_impl(T&& t) +// SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator::value)) +// { +// return sprout::generators::next_generator(sprout::forward(t)); +// } template< typename T, typename sprout::enabler_if::value>::type = sprout::enabler @@ -167,16 +179,6 @@ namespace sprout_generator_detail { { return sprout::forward(t).next_generator(); } - template< - typename T, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout_generator_detail::next_generator_result::type - next_generator_impl(T&& t) - SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator::value)) - { - return next_generator(sprout::forward(t)); - } template< typename T, typename sprout::enabler_if::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::value)) { - return sprout::tuples::get<1>(sprout::forward(t)); + return get<1>(sprout::forward(t)); } } // namespace sprout_generator_detail diff --git a/sprout/iterator/bytes_iterator.hpp b/sprout/iterator/bytes_iterator.hpp index 4192e3c4..0e7db44d 100644 --- a/sprout/iterator/bytes_iterator.hpp +++ b/sprout/iterator/bytes_iterator.hpp @@ -162,6 +162,18 @@ namespace sprout { } }; + // + // make_bytes_iterator + // + template + inline SPROUT_CONSTEXPR sprout::bytes_iterator make_bytes_iterator(Iterator it) { + return sprout::bytes_iterator(it); + } + template + inline SPROUT_CONSTEXPR sprout::bytes_iterator make_bytes_iterator(Iterator it, Traits) { + return sprout::bytes_iterator(it); + } + // // swap // @@ -170,44 +182,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::bytes_iterator next( - sprout::bytes_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::bytes_iterator next( - sprout::bytes_iterator const& it, - typename sprout::bytes_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::bytes_iterator prev( - sprout::bytes_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::bytes_iterator prev( - sprout::bytes_iterator const& it, - typename sprout::bytes_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -222,15 +196,41 @@ namespace sprout { } // - // make_bytes_iterator + // iterator_next // - template - inline SPROUT_CONSTEXPR sprout::bytes_iterator make_bytes_iterator(Iterator it) { - return sprout::bytes_iterator(it); + template + inline SPROUT_CONSTEXPR sprout::bytes_iterator iterator_next( + sprout::bytes_iterator const& it + ) + { + return it.next(); } template - inline SPROUT_CONSTEXPR sprout::bytes_iterator make_bytes_iterator(Iterator it, Traits) { - return sprout::bytes_iterator(it); + inline SPROUT_CONSTEXPR sprout::bytes_iterator iterator_next( + sprout::bytes_iterator const& it, + typename sprout::bytes_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::bytes_iterator iterator_prev( + sprout::bytes_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::bytes_iterator iterator_prev( + sprout::bytes_iterator const& it, + typename sprout::bytes_iterator::difference_type n + ) + { + return it - n; } } // namespace sprout diff --git a/sprout/iterator/counting_iterator.hpp b/sprout/iterator/counting_iterator.hpp index f148fe35..71506c4d 100644 --- a/sprout/iterator/counting_iterator.hpp +++ b/sprout/iterator/counting_iterator.hpp @@ -190,44 +190,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::counting_iterator next( - sprout::counting_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::counting_iterator next( - sprout::counting_iterator const& it, - typename sprout::counting_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::counting_iterator prev( - sprout::counting_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::counting_iterator prev( - sprout::counting_iterator const& it, - typename sprout::counting_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -240,6 +202,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::counting_iterator iterator_next( + sprout::counting_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::counting_iterator iterator_next( + sprout::counting_iterator const& it, + typename sprout::counting_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::counting_iterator iterator_prev( + sprout::counting_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::counting_iterator iterator_prev( + sprout::counting_iterator const& it, + typename sprout::counting_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP diff --git a/sprout/iterator/filter_iterator.hpp b/sprout/iterator/filter_iterator.hpp index 321f8fb7..738e85d5 100644 --- a/sprout/iterator/filter_iterator.hpp +++ b/sprout/iterator/filter_iterator.hpp @@ -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 - inline SPROUT_CONSTEXPR sprout::filter_iterator next( + inline SPROUT_CONSTEXPR sprout::filter_iterator iterator_next( sprout::filter_iterator const& it ) { @@ -188,10 +188,10 @@ namespace sprout { } // - // prev + // iterator_prev // template - inline SPROUT_CONSTEXPR sprout::filter_iterator prev( + inline SPROUT_CONSTEXPR sprout::filter_iterator iterator_prev( sprout::filter_iterator const& it ) { diff --git a/sprout/iterator/index_iterator.hpp b/sprout/iterator/index_iterator.hpp index 8926377b..4339acab 100644 --- a/sprout/iterator/index_iterator.hpp +++ b/sprout/iterator/index_iterator.hpp @@ -195,44 +195,6 @@ namespace sprout { : public std::true_type {}; - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::index_iterator next( - sprout::index_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::index_iterator next( - sprout::index_iterator const& it, - typename sprout::index_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::index_iterator prev( - sprout::index_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::index_iterator prev( - sprout::index_iterator const& it, - typename sprout::index_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -245,6 +207,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::index_iterator iterator_next( + sprout::index_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::index_iterator iterator_next( + sprout::index_iterator const& it, + typename sprout::index_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::index_iterator iterator_prev( + sprout::index_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::index_iterator iterator_prev( + sprout::index_iterator const& it, + typename sprout::index_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_INDEX_ITERATOR_HPP diff --git a/sprout/iterator/next.hpp b/sprout/iterator/next.hpp index 5f42f8da..41780c74 100644 --- a/sprout/iterator/next.hpp +++ b/sprout/iterator/next.hpp @@ -4,73 +4,94 @@ #include #include #include -#include namespace sprout { - namespace detail { + namespace iterator_detail { template inline SPROUT_CONSTEXPR typename std::enable_if< - std::is_literal_type::type>::value, - typename std::decay::type + std::is_literal_type::value, + RandomAccessIterator >::type next_impl( - RandomAccessIterator&& it, + RandomAccessIterator const& it, std::random_access_iterator_tag* ) { - return sprout::forward(it) + 1; + return it + 1; } template - inline SPROUT_CONSTEXPR typename std::decay::type next_impl( - ForwardIterator&& it, + inline SPROUT_CONSTEXPR ForwardIterator next_impl( + ForwardIterator const& it, void* ) { - return std::next(sprout::forward(it)); + return std::next(it); } template inline SPROUT_CONSTEXPR typename std::enable_if< - std::is_literal_type::type>::value, - typename std::decay::type + std::is_literal_type::value, + RandomAccessIterator >::type next_impl( - RandomAccessIterator&& it, - typename std::iterator_traits::type>::difference_type n, + RandomAccessIterator const& it, + typename std::iterator_traits::difference_type n, std::random_access_iterator_tag* ) { - return sprout::forward(it) + n; + return it + n; } template - inline SPROUT_CONSTEXPR typename std::decay::type next_impl( - ForwardIterator it, - typename std::iterator_traits::type>::difference_type n, + inline SPROUT_CONSTEXPR ForwardIterator next_impl( + ForwardIterator const& it, + typename std::iterator_traits::difference_type n, void* ) { - return std::next(sprout::forward(it), n); + return std::next(it, n); } - } // namespace detail + + template + inline SPROUT_CONSTEXPR ForwardIterator + iterator_next(ForwardIterator const& it) { + typedef typename std::iterator_traits::iterator_category* category; + return sprout::iterator_detail::next_impl(it, category()); + } + template + inline SPROUT_CONSTEXPR ForwardIterator + iterator_next(ForwardIterator const& it, typename std::iterator_traits::difference_type n) { + typedef typename std::iterator_traits::iterator_category* category; + return sprout::iterator_detail::next_impl(it, n, category()); + } + } // namespace iterator_detail +} // namespace sprout + +namespace sprout_iterator_detail { + template + inline SPROUT_CONSTEXPR ForwardIterator + next(ForwardIterator const& it) { + using sprout::iterator_detail::iterator_next; + return iterator_next(it); + } + template + inline SPROUT_CONSTEXPR ForwardIterator + next(ForwardIterator const& it, typename std::iterator_traits::difference_type n) { + using sprout::iterator_detail::iterator_next; + return iterator_next(it, n); + } +} // namespace sprout_iterator_detail + +namespace sprout { // // next // template - inline SPROUT_CONSTEXPR typename std::decay::type - next(ForwardIterator&& it) { - typedef typename std::iterator_traits::type>::iterator_category* category; - return sprout::detail::next_impl( - sprout::forward(it), - category() - ); + inline SPROUT_CONSTEXPR ForwardIterator + next(ForwardIterator const& it) { + return sprout_iterator_detail::next(it); } template - inline SPROUT_CONSTEXPR typename std::decay::type - next(ForwardIterator&& it, typename std::iterator_traits::type>::difference_type n) { - typedef typename std::iterator_traits::type>::iterator_category* category; - return sprout::detail::next_impl( - sprout::forward(it), - n, - category() - ); + inline SPROUT_CONSTEXPR ForwardIterator + next(ForwardIterator const& it, typename std::iterator_traits::difference_type n) { + return sprout_iterator_detail::next(it, n); } } // namespace sprout diff --git a/sprout/iterator/prev.hpp b/sprout/iterator/prev.hpp index f371045d..679a9bf4 100644 --- a/sprout/iterator/prev.hpp +++ b/sprout/iterator/prev.hpp @@ -4,73 +4,94 @@ #include #include #include -#include namespace sprout { - namespace detail { + namespace iterator_detail { template inline SPROUT_CONSTEXPR typename std::enable_if< - std::is_literal_type::type>::value, - typename std::decay::type + std::is_literal_type::value, + RandomAccessIterator >::type prev_impl( - RandomAccessIterator&& it, + RandomAccessIterator const& it, std::random_access_iterator_tag* ) { - return sprout::forward(it) - 1; + return it - 1; } template - inline SPROUT_CONSTEXPR typename std::decay::type prev_impl( - BidirectionalIterator&& it, + inline SPROUT_CONSTEXPR BidirectionalIterator prev_impl( + BidirectionalIterator const& it, void* ) { - return std::prev(sprout::forward(it)); + return std::prev(it); } template inline SPROUT_CONSTEXPR typename std::enable_if< - std::is_literal_type::type>::value, - typename std::decay::type + std::is_literal_type::value, + RandomAccessIterator >::type prev_impl( - RandomAccessIterator&& it, - typename std::iterator_traits::type>::difference_type n, + RandomAccessIterator const& it, + typename std::iterator_traits::difference_type n, std::random_access_iterator_tag* ) { - return sprout::forward(it) - n; + return it - n; } template - inline SPROUT_CONSTEXPR typename std::decay::type prev_impl( - BidirectionalIterator it, - typename std::iterator_traits::type>::difference_type n, + inline SPROUT_CONSTEXPR BidirectionalIterator prev_impl( + BidirectionalIterator const& it, + typename std::iterator_traits::difference_type n, void* ) { - return std::prev(sprout::forward(it), n); + return std::prev(it, n); } - } // namespace detail + + template + inline SPROUT_CONSTEXPR BidirectionalIterator + iterator_prev(BidirectionalIterator const& it) { + typedef typename std::iterator_traits::iterator_category* category; + return sprout::iterator_detail::prev_impl(it, category()); + } + template + inline SPROUT_CONSTEXPR BidirectionalIterator + iterator_prev(BidirectionalIterator const& it, typename std::iterator_traits::difference_type n) { + typedef typename std::iterator_traits::iterator_category* category; + return sprout::iterator_detail::prev_impl(it, n, category()); + } + } // namespace iterator_detail +} // namespace sprout + +namespace sprout_iterator_detail { + template + inline SPROUT_CONSTEXPR BidirectionalIterator + prev(BidirectionalIterator const& it) { + using sprout::iterator_detail::iterator_prev; + return iterator_prev(it); + } + template + inline SPROUT_CONSTEXPR BidirectionalIterator + prev(BidirectionalIterator const& it, typename std::iterator_traits::difference_type n) { + using sprout::iterator_detail::iterator_prev; + return iterator_prev(it, n); + } +} // namespace sprout_iterator_detail + +namespace sprout { // // prev // template - inline SPROUT_CONSTEXPR typename std::decay::type - prev(BidirectionalIterator&& it) { - typedef typename std::iterator_traits::type>::iterator_category* category; - return sprout::detail::prev_impl( - sprout::forward(it), - category() - ); + inline SPROUT_CONSTEXPR BidirectionalIterator + prev(BidirectionalIterator const& it) { + return sprout_iterator_detail::prev(it); } template - inline SPROUT_CONSTEXPR typename std::decay::type - prev(BidirectionalIterator&& it, typename std::iterator_traits::type>::difference_type n) { - typedef typename std::iterator_traits::type>::iterator_category* category; - return sprout::detail::prev_impl( - sprout::forward(it), - n, - category() - ); + inline SPROUT_CONSTEXPR BidirectionalIterator + prev(BidirectionalIterator const& it, typename std::iterator_traits::difference_type n) { + return sprout_iterator_detail::prev(it, n); } } // namespace sprout diff --git a/sprout/iterator/reverse_iterator.hpp b/sprout/iterator/reverse_iterator.hpp index 0b95a76a..0b1a3d93 100644 --- a/sprout/iterator/reverse_iterator.hpp +++ b/sprout/iterator/reverse_iterator.hpp @@ -199,44 +199,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::reverse_iterator next( - sprout::reverse_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::reverse_iterator next( - sprout::reverse_iterator const& it, - typename sprout::reverse_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::reverse_iterator prev( - sprout::reverse_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::reverse_iterator prev( - sprout::reverse_iterator const& it, - typename sprout::reverse_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -249,6 +211,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::reverse_iterator iterator_next( + sprout::reverse_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::reverse_iterator iterator_next( + sprout::reverse_iterator const& it, + typename sprout::reverse_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::reverse_iterator iterator_prev( + sprout::reverse_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::reverse_iterator iterator_prev( + sprout::reverse_iterator const& it, + typename sprout::reverse_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_REVERSE_ITERATOR_HPP diff --git a/sprout/iterator/sawtooth_iterator.hpp b/sprout/iterator/sawtooth_iterator.hpp index 0f3c0db2..d225f0f1 100644 --- a/sprout/iterator/sawtooth_iterator.hpp +++ b/sprout/iterator/sawtooth_iterator.hpp @@ -218,44 +218,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::sawtooth_iterator next( - sprout::sawtooth_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::sawtooth_iterator next( - sprout::sawtooth_iterator const& it, - typename sprout::sawtooth_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::sawtooth_iterator prev( - sprout::sawtooth_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::sawtooth_iterator prev( - sprout::sawtooth_iterator const& it, - typename sprout::sawtooth_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -268,6 +230,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::sawtooth_iterator iterator_next( + sprout::sawtooth_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::sawtooth_iterator iterator_next( + sprout::sawtooth_iterator const& it, + typename sprout::sawtooth_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::sawtooth_iterator iterator_prev( + sprout::sawtooth_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::sawtooth_iterator iterator_prev( + sprout::sawtooth_iterator const& it, + typename sprout::sawtooth_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_SAWTOOTH_ITERATOR_HPP diff --git a/sprout/iterator/sinusoid_iterator.hpp b/sprout/iterator/sinusoid_iterator.hpp index 9fb4f397..df8e6d44 100644 --- a/sprout/iterator/sinusoid_iterator.hpp +++ b/sprout/iterator/sinusoid_iterator.hpp @@ -227,44 +227,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::sinusoid_iterator next( - sprout::sinusoid_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::sinusoid_iterator next( - sprout::sinusoid_iterator const& it, - typename sprout::sinusoid_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::sinusoid_iterator prev( - sprout::sinusoid_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::sinusoid_iterator prev( - sprout::sinusoid_iterator const& it, - typename sprout::sinusoid_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -277,6 +239,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::sinusoid_iterator iterator_next( + sprout::sinusoid_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::sinusoid_iterator iterator_next( + sprout::sinusoid_iterator const& it, + typename sprout::sinusoid_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::sinusoid_iterator iterator_prev( + sprout::sinusoid_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::sinusoid_iterator iterator_prev( + sprout::sinusoid_iterator const& it, + typename sprout::sinusoid_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_SINUSOID_ITERATOR_HPP diff --git a/sprout/iterator/size_enum_iterator.hpp b/sprout/iterator/size_enum_iterator.hpp index 472e6566..5635d544 100644 --- a/sprout/iterator/size_enum_iterator.hpp +++ b/sprout/iterator/size_enum_iterator.hpp @@ -392,44 +392,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::size_enum_iterator next( - sprout::size_enum_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::size_enum_iterator next( - sprout::size_enum_iterator const& it, - typename sprout::size_enum_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::size_enum_iterator prev( - sprout::size_enum_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::size_enum_iterator prev( - sprout::size_enum_iterator const& it, - typename sprout::size_enum_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -442,6 +404,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::size_enum_iterator iterator_next( + sprout::size_enum_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::size_enum_iterator iterator_next( + sprout::size_enum_iterator const& it, + typename sprout::size_enum_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::size_enum_iterator iterator_prev( + sprout::size_enum_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::size_enum_iterator iterator_prev( + sprout::size_enum_iterator const& it, + typename sprout::size_enum_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_SIZE_ENUM_ITERATOR_HPP diff --git a/sprout/iterator/square_iterator.hpp b/sprout/iterator/square_iterator.hpp index d3b50b98..a59bb3e9 100644 --- a/sprout/iterator/square_iterator.hpp +++ b/sprout/iterator/square_iterator.hpp @@ -228,44 +228,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::square_iterator next( - sprout::square_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::square_iterator next( - sprout::square_iterator const& it, - typename sprout::square_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::square_iterator prev( - sprout::square_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::square_iterator prev( - sprout::square_iterator const& it, - typename sprout::square_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -278,6 +240,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::square_iterator iterator_next( + sprout::square_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::square_iterator iterator_next( + sprout::square_iterator const& it, + typename sprout::square_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::square_iterator iterator_prev( + sprout::square_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::square_iterator iterator_prev( + sprout::square_iterator const& it, + typename sprout::square_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_SQUARE_ITERATOR_HPP diff --git a/sprout/iterator/transform_iterator.hpp b/sprout/iterator/transform_iterator.hpp index 4c36643b..7b0bed94 100644 --- a/sprout/iterator/transform_iterator.hpp +++ b/sprout/iterator/transform_iterator.hpp @@ -386,44 +386,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::transform_iterator next( - sprout::transform_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::transform_iterator next( - sprout::transform_iterator const& it, - typename sprout::transform_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::transform_iterator prev( - sprout::transform_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::transform_iterator prev( - sprout::transform_iterator const& it, - typename sprout::transform_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -436,6 +398,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::transform_iterator iterator_next( + sprout::transform_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::transform_iterator iterator_next( + sprout::transform_iterator const& it, + typename sprout::transform_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::transform_iterator iterator_prev( + sprout::transform_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::transform_iterator iterator_prev( + sprout::transform_iterator const& it, + typename sprout::transform_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_TRANSFORM_ITERATOR_HPP diff --git a/sprout/iterator/triangle_iterator.hpp b/sprout/iterator/triangle_iterator.hpp index 9f031c2f..22b9ea9d 100644 --- a/sprout/iterator/triangle_iterator.hpp +++ b/sprout/iterator/triangle_iterator.hpp @@ -218,44 +218,6 @@ namespace sprout { lhs.swap(rhs); } - // - // next - // - template - inline SPROUT_CONSTEXPR sprout::triangle_iterator next( - sprout::triangle_iterator const& it - ) - { - return it.next(); - } - template - inline SPROUT_CONSTEXPR sprout::triangle_iterator next( - sprout::triangle_iterator const& it, - typename sprout::triangle_iterator::difference_type n - ) - { - return it + n; - } - - // - // prev - // - template - inline SPROUT_CONSTEXPR sprout::triangle_iterator prev( - sprout::triangle_iterator const& it - ) - { - return it.prev(); - } - template - inline SPROUT_CONSTEXPR sprout::triangle_iterator prev( - sprout::triangle_iterator const& it, - typename sprout::triangle_iterator::difference_type n - ) - { - return it - n; - } - // // distance // @@ -268,6 +230,44 @@ namespace sprout { { return last - first; } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::triangle_iterator iterator_next( + sprout::triangle_iterator const& it + ) + { + return it.next(); + } + template + inline SPROUT_CONSTEXPR sprout::triangle_iterator iterator_next( + sprout::triangle_iterator const& it, + typename sprout::triangle_iterator::difference_type n + ) + { + return it + n; + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::triangle_iterator iterator_prev( + sprout::triangle_iterator const& it + ) + { + return it.prev(); + } + template + inline SPROUT_CONSTEXPR sprout::triangle_iterator iterator_prev( + sprout::triangle_iterator const& it, + typename sprout::triangle_iterator::difference_type n + ) + { + return it - n; + } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_TRIANGLE_ITERATOR_HPP diff --git a/sprout/iterator/value_iterator.hpp b/sprout/iterator/value_iterator.hpp index 215a7ec9..c5b1f0cd 100644 --- a/sprout/iterator/value_iterator.hpp +++ b/sprout/iterator/value_iterator.hpp @@ -165,17 +165,26 @@ namespace sprout { } // - // next + // distance // template - inline SPROUT_CONSTEXPR sprout::value_iterator next( + inline SPROUT_CONSTEXPR typename std::iterator_traits >::difference_type + distance(sprout::value_iterator first, sprout::value_iterator last) { + return last - first; + } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::value_iterator iterator_next( sprout::value_iterator const& it ) { return it.next(); } template - inline SPROUT_CONSTEXPR sprout::value_iterator next( + inline SPROUT_CONSTEXPR sprout::value_iterator iterator_next( sprout::value_iterator const& it, typename sprout::value_iterator::difference_type n ) @@ -184,32 +193,23 @@ namespace sprout { } // - // prev + // iterator_prev // template - inline SPROUT_CONSTEXPR sprout::value_iterator prev( + inline SPROUT_CONSTEXPR sprout::value_iterator iterator_prev( sprout::value_iterator const& it ) { return it.prev(); } template - inline SPROUT_CONSTEXPR sprout::value_iterator prev( + inline SPROUT_CONSTEXPR sprout::value_iterator iterator_prev( sprout::value_iterator const& it, typename sprout::value_iterator::difference_type n ) { return it - n; } - - // - // distance - // - template - inline SPROUT_CONSTEXPR typename std::iterator_traits >::difference_type - distance(sprout::value_iterator first, sprout::value_iterator last) { - return last - first; - } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_VALUE_ITERATOR_HPP diff --git a/sprout/random/random_iterator.hpp b/sprout/random/random_iterator.hpp index ccfc9258..addb305a 100644 --- a/sprout/random/random_iterator.hpp +++ b/sprout/random/random_iterator.hpp @@ -306,10 +306,10 @@ namespace sprout { } // - // next + // iterator_next // template - SPROUT_CONSTEXPR sprout::random::random_iterator next( + SPROUT_CONSTEXPR sprout::random::random_iterator iterator_next( sprout::random::random_iterator const& it ) { diff --git a/sprout/random/random_result.hpp b/sprout/random/random_result.hpp index f9c1cc81..f7000778 100644 --- a/sprout/random/random_result.hpp +++ b/sprout/random/random_result.hpp @@ -230,6 +230,7 @@ namespace sprout { return result; } }; + // // swap // @@ -241,18 +242,18 @@ namespace sprout { { lhs.swap(rhs); } - } // namespace random - // - // next - // - template - SPROUT_CONSTEXPR sprout::random::random_result next( - sprout::random::random_result const& it - ) - { - return it(); - } + // + // next + // + template + SPROUT_CONSTEXPR sprout::random::random_result next( + sprout::random::random_result const& it + ) + { + return it(); + } + } // namespace random using sprout::random::random_result; } // namespace sprout diff --git a/sprout/tuple/tuple/get.hpp b/sprout/tuple/tuple/get.hpp index 30e0556a..bf70d2dd 100644 --- a/sprout/tuple/tuple/get.hpp +++ b/sprout/tuple/tuple/get.hpp @@ -91,26 +91,19 @@ namespace sprout { } // namespace sprout namespace sprout_tuple_detail { - struct not_found_adl_get {}; - - template - sprout_tuple_detail::not_found_adl_get get(...); - template - struct has_adl_get_test { + struct has_spr_get_test { public: template< typename U = T, - typename sprout::enabler_if< - !std::is_same(std::declval())), sprout_tuple_detail::not_found_adl_get>::value - >::type = sprout::enabler + typename = decltype(sprout::tuples::get(std::declval())) > static std::true_type test(int); static std::false_type test(...); }; template - struct has_adl_get - : public decltype(sprout_tuple_detail::has_adl_get_test::test(0)) + struct has_spr_get + : public decltype(sprout_tuple_detail::has_spr_get_test::test(0)) {}; template @@ -129,18 +122,18 @@ namespace sprout_tuple_detail { {}; template - struct select_adl_get; + struct select_spr_get; template - struct select_adl_get< + struct select_spr_get< I, T, - typename std::enable_if::value>::type + typename std::enable_if::value>::type > : public std::true_type {}; template - struct select_adl_get< + struct select_spr_get< I, T, - typename std::enable_if::value>::type + typename std::enable_if::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::value - && !sprout_tuple_detail::has_adl_get::value + && !sprout_tuple_detail::has_spr_get::value >::type > : public std::true_type @@ -162,7 +155,7 @@ namespace sprout_tuple_detail { I, T, typename std::enable_if::value - && !sprout_tuple_detail::has_adl_get::value + && !sprout_tuple_detail::has_spr_get::value )>::type > : public std::false_type @@ -170,10 +163,10 @@ namespace sprout_tuple_detail { template struct noexcept_get; - template - struct noexcept_get::value>::type> - : public std::integral_constant(std::declval()), false)> - {}; +// template +// struct noexcept_get::value>::type> +// : public std::integral_constant(std::declval()), false)> +// {}; template struct noexcept_get::value>::type> : public std::integral_constant(std::declval()), false)> @@ -181,27 +174,27 @@ namespace sprout_tuple_detail { template struct get_result; - template - struct get_result::value>::type> { - public: - typedef decltype(get(std::declval())) type; - }; +// template +// struct get_result::value>::type> { +// public: +// typedef decltype(sprout::tuples::get(std::declval())) type; +// }; template struct get_result::value>::type> { public: typedef decltype(std::get(std::declval())) type; }; - template< - std::size_t I, typename T, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout_tuple_detail::get_result::type - get_impl(T&& t) - SPROUT_NOEXCEPT_EXPR((sprout_tuple_detail::noexcept_get::value)) - { - return get(sprout::forward(t)); - } +// template< +// std::size_t I, typename T, +// typename sprout::enabler_if::value>::type = sprout::enabler +// > +// inline SPROUT_CONSTEXPR typename sprout_tuple_detail::get_result::type +// get_impl(T&& t) +// SPROUT_NOEXCEPT_EXPR((sprout_tuple_detail::noexcept_get::value)) +// { +// return sprout::tuples::get(sprout::forward(t)); +// } template< std::size_t I, typename T, typename sprout::enabler_if::value>::type = sprout::enabler