1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-02-25 21:43:57 +00:00

fix iterator implementation

This commit is contained in:
bolero-MURAKAMI 2013-02-23 15:21:27 +09:00
parent 4c996bd47b
commit 7c706381d4
65 changed files with 494 additions and 313 deletions

View file

@ -109,7 +109,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR ForwardIterator inline SPROUT_CONSTEXPR ForwardIterator
adjacent_find( adjacent_find(
ForwardIterator first, ForwardIterator last, BinaryPredicate pred, ForwardIterator first, ForwardIterator last, BinaryPredicate pred,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::pair<ForwardIterator, ForwardIterator> type; typedef sprout::pair<ForwardIterator, ForwardIterator> type;

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
all_of( all_of(
InputIterator first, InputIterator last, Predicate pred, InputIterator first, InputIterator last, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
all_of_equal( all_of_equal(
InputIterator first, InputIterator last, T const& value, InputIterator first, InputIterator last, T const& value,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
any_of( any_of(
InputIterator first, InputIterator last, Predicate pred, InputIterator first, InputIterator last, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
any_of_equal( any_of_equal(
InputIterator first, InputIterator last, T const& value, InputIterator first, InputIterator last, T const& value,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
count( count(
InputIterator first, InputIterator last, T const& value, InputIterator first, InputIterator last, T const& value,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
count_if( count_if(
InputIterator first, InputIterator last, Predicate pred, InputIterator first, InputIterator last, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;

View file

@ -91,7 +91,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
equal( equal(
InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type; typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type;

View file

@ -86,7 +86,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR InputIterator inline SPROUT_CONSTEXPR InputIterator
find( find(
InputIterator first, InputIterator last, T const& value, InputIterator first, InputIterator last, T const& value,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -134,7 +134,7 @@ namespace sprout {
ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2, ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred, BinaryPredicate pred,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::pair<ForwardIterator1, ForwardIterator1> type; typedef sprout::pair<ForwardIterator1, ForwardIterator1> type;

View file

@ -102,7 +102,7 @@ namespace sprout {
InputIterator1 first1, InputIterator1 last1, InputIterator1 first1, InputIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2, ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred, BinaryPredicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator1, bool> type; typedef sprout::pair<InputIterator1, bool> type;

View file

@ -86,7 +86,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR InputIterator inline SPROUT_CONSTEXPR InputIterator
find_if( find_if(
InputIterator first, InputIterator last, Predicate pred, InputIterator first, InputIterator last, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -86,7 +86,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR InputIterator inline SPROUT_CONSTEXPR InputIterator
find_if_not( find_if_not(
InputIterator first, InputIterator last, Predicate pred, InputIterator first, InputIterator last, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -105,7 +105,7 @@ namespace sprout {
typename std::iterator_traits<InputIterator>::value_type const& low, typename std::iterator_traits<InputIterator>::value_type const& low,
typename std::iterator_traits<InputIterator>::value_type const& high, typename std::iterator_traits<InputIterator>::value_type const& high,
Compare comp, Compare comp,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::clamp_range_copy_impl(first, last, result, low, high, comp, sprout::size(result)); return sprout::fixed::detail::clamp_range_copy_impl(first, last, result, low, high, comp, sprout::size(result));

View file

@ -83,7 +83,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
copy( copy(
InputIterator first, InputIterator last, Result const& result, InputIterator first, InputIterator last, Result const& result,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::copy_impl(first, last, result, sprout::size(result)); return sprout::fixed::detail::copy_impl(first, last, result, sprout::size(result));

View file

@ -82,7 +82,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
copy_backward( copy_backward(
BidirectionalIterator first, BidirectionalIterator last, Result const& result, BidirectionalIterator first, BidirectionalIterator last, Result const& result,
void* std::bidirectional_iterator_tag*
) )
{ {
return sprout::fixed::detail::copy_backward_impl( return sprout::fixed::detail::copy_backward_impl(

View file

@ -59,7 +59,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
copy_n( copy_n(
InputIterator first, Size n, Result const& result, InputIterator first, Size n, Result const& result,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::copy_n_impl(first, n, result, sprout::size(result)); return sprout::fixed::detail::copy_n_impl(first, n, result, sprout::size(result));

View file

@ -61,7 +61,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
copy_until( copy_until(
InputIterator first, InputIterator last, Result const& result, Predicate pred, InputIterator first, InputIterator last, Result const& result, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::copy_until_impl(first, last, result, pred, sprout::size(result)); return sprout::fixed::detail::copy_until_impl(first, last, result, pred, sprout::size(result));

View file

@ -60,7 +60,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
copy_while( copy_while(
InputIterator first, InputIterator last, Result const& result, Predicate pred, InputIterator first, InputIterator last, Result const& result, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::copy_while_impl(first, last, result, pred, sprout::size(result)); return sprout::fixed::detail::copy_while_impl(first, last, result, pred, sprout::size(result));

View file

@ -93,7 +93,7 @@ namespace sprout {
replace_copy( replace_copy(
InputIterator first, InputIterator last, InputIterator first, InputIterator last,
Result const& result, T const& old_value, T const& new_value, Result const& result, T const& old_value, T const& new_value,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::replace_copy_impl(first, last, result, old_value, new_value, sprout::size(result)); return sprout::fixed::detail::replace_copy_impl(first, last, result, old_value, new_value, sprout::size(result));

View file

@ -92,7 +92,7 @@ namespace sprout {
replace_copy_if( replace_copy_if(
InputIterator first, InputIterator last, InputIterator first, InputIterator last,
Result const& result, Predicate pred, T const& new_value, Result const& result, Predicate pred, T const& new_value,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::replace_copy_if_impl(first, last, result, pred, new_value, sprout::size(result)); return sprout::fixed::detail::replace_copy_if_impl(first, last, result, pred, new_value, sprout::size(result));

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
reverse_copy( reverse_copy(
BidirectionalIterator first, BidirectionalIterator last, Result const& result, BidirectionalIterator first, BidirectionalIterator last, Result const& result,
void* std::bidirectional_iterator_tag*
) )
{ {
return sprout::fixed::detail::reverse_copy_impl(first, last, result, sprout::size(result)); return sprout::fixed::detail::reverse_copy_impl(first, last, result, sprout::size(result));

View file

@ -125,7 +125,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
rotate_copy( rotate_copy(
ForwardIterator first, ForwardIterator middle, ForwardIterator last, Result const& result, ForwardIterator first, ForwardIterator middle, ForwardIterator last, Result const& result,
void* std::forward_iterator_tag*
) )
{ {
return sprout::fixed::detail::rotate_copy_impl(first, middle, last, result, sprout::size(result)); return sprout::fixed::detail::rotate_copy_impl(first, middle, last, result, sprout::size(result));

View file

@ -102,7 +102,7 @@ namespace sprout {
ForwardIterator first, ForwardIterator last, ForwardIterator first, ForwardIterator last,
Result const& result, Result const& result,
ForwardIterator pos1, ForwardIterator pos2, ForwardIterator pos1, ForwardIterator pos2,
void* std::forward_iterator_tag*
) )
{ {
return sprout::fixed::detail::swap_element_copy_impl(first, last, result, sprout::size(result)); return sprout::fixed::detail::swap_element_copy_impl(first, last, result, sprout::size(result));

View file

@ -90,7 +90,7 @@ namespace sprout {
transform( transform(
InputIterator first, InputIterator last, InputIterator first, InputIterator last,
Result const& result, UnaryOperation op, Result const& result, UnaryOperation op,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::transform_impl(first, last, result, op, sprout::size(result)); return sprout::fixed::detail::transform_impl(first, last, result, op, sprout::size(result));
@ -207,7 +207,7 @@ namespace sprout {
transform( transform(
InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
Result const& result, BinaryOperation op, Result const& result, BinaryOperation op,
void* std::input_iterator_tag*
) )
{ {
return sprout::fixed::detail::transform_impl(first1, last1, first2, result, op, sprout::size(result)); return sprout::fixed::detail::transform_impl(first1, last1, first2, result, op, sprout::size(result));

View file

@ -99,7 +99,7 @@ namespace sprout {
InputIterator1 first1, InputIterator1 last1, InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, InputIterator2 first2, InputIterator2 last2,
Compare comp, Compare comp,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator1, InputIterator2> type; typedef sprout::pair<InputIterator1, InputIterator2> type;

View file

@ -78,7 +78,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
is_partitioned( is_partitioned(
InputIterator first, InputIterator last, Predicate pred, InputIterator first, InputIterator last, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;

View file

@ -99,7 +99,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
is_permutation( is_permutation(
ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::pair<ForwardIterator1, bool> type; typedef sprout::pair<ForwardIterator1, bool> type;

View file

@ -52,7 +52,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
is_sorted( is_sorted(
ForwardIterator first, ForwardIterator last, Compare comp, ForwardIterator first, ForwardIterator last, Compare comp,
void* std::forward_iterator_tag*
) )
{ {
return sprout::is_sorted_until(first, last, comp) == last; return sprout::is_sorted_until(first, last, comp) == last;

View file

@ -94,7 +94,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR ForwardIterator inline SPROUT_CONSTEXPR ForwardIterator
is_sorted_until( is_sorted_until(
ForwardIterator first, ForwardIterator last, Compare comp, ForwardIterator first, ForwardIterator last, Compare comp,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::pair<ForwardIterator, ForwardIterator> type; typedef sprout::pair<ForwardIterator, ForwardIterator> type;

View file

@ -126,7 +126,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
lexicographical_compare( lexicographical_compare(
InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator1, InputIterator2> type; typedef sprout::pair<InputIterator1, InputIterator2> type;

View file

@ -97,7 +97,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR ForwardIterator inline SPROUT_CONSTEXPR ForwardIterator
max_element( max_element(
ForwardIterator first, ForwardIterator last, Compare comp, ForwardIterator first, ForwardIterator last, Compare comp,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::pair<ForwardIterator, ForwardIterator> type; typedef sprout::pair<ForwardIterator, ForwardIterator> type;

View file

@ -97,7 +97,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR ForwardIterator inline SPROUT_CONSTEXPR ForwardIterator
min_element( min_element(
ForwardIterator first, ForwardIterator last, Compare comp, ForwardIterator first, ForwardIterator last, Compare comp,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::pair<ForwardIterator, ForwardIterator> type; typedef sprout::pair<ForwardIterator, ForwardIterator> type;

View file

@ -109,7 +109,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator> inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator>
minmax_element( minmax_element(
ForwardIterator first, ForwardIterator last, Compare comp, ForwardIterator first, ForwardIterator last, Compare comp,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::pair<ForwardIterator, sprout::pair<ForwardIterator, ForwardIterator> > type; typedef sprout::pair<ForwardIterator, sprout::pair<ForwardIterator, ForwardIterator> > type;

View file

@ -112,7 +112,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2> inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
mismatch( mismatch(
InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type; typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type;

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
none_of( none_of(
InputIterator first, InputIterator last, Predicate pred, InputIterator first, InputIterator last, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -84,7 +84,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
none_of_equal( none_of_equal(
InputIterator first, InputIterator last, T const& value, InputIterator first, InputIterator last, T const& value,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, bool> type; typedef sprout::pair<InputIterator, bool> type;

View file

@ -108,7 +108,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
one_of( one_of(
InputIterator first, InputIterator last, Predicate pred, InputIterator first, InputIterator last, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;

View file

@ -108,7 +108,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR bool inline SPROUT_CONSTEXPR bool
one_of_equal( one_of_equal(
InputIterator first, InputIterator last, T const& value, InputIterator first, InputIterator last, T const& value,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;

View file

@ -110,7 +110,7 @@ namespace sprout {
ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2, ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred, BinaryPredicate pred,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::pair<ForwardIterator1, bool> type; typedef sprout::pair<ForwardIterator1, bool> type;

View file

@ -18,9 +18,10 @@ namespace sprout {
inline SPROUT_CONSTEXPR ForwardIterator inline SPROUT_CONSTEXPR ForwardIterator
search_n(ForwardIterator first, ForwardIterator last, Size count, T const& value, BinaryPredicate pred) { search_n(ForwardIterator first, ForwardIterator last, Size count, T const& value, BinaryPredicate pred) {
typedef sprout::value_iterator<T const&> iterator; typedef sprout::value_iterator<T const&> iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type;
return sprout::search( return sprout::search(
first, last, first, last,
iterator(value, static_cast<typename std::iterator_traits<iterator>::difference_type>(count)), iterator(value, 0), iterator(value, static_cast<difference_type>(count)), iterator(value, 0),
pred pred
); );
} }

View file

@ -129,7 +129,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR int inline SPROUT_CONSTEXPR int
tristate_lexicographical_compare( tristate_lexicographical_compare(
InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator1, InputIterator2> type; typedef sprout::pair<InputIterator1, InputIterator2> type;
@ -298,7 +298,7 @@ namespace sprout {
InputIterator1 first1, InputIterator1 last1, T1 const& delim1, InputIterator1 first1, InputIterator1 last1, T1 const& delim1,
InputIterator2 first2, InputIterator2 last2, T2 const& delim2, InputIterator2 first2, InputIterator2 last2, T2 const& delim2,
Compare comp, Compare comp,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator1, InputIterator2> type; typedef sprout::pair<InputIterator1, InputIterator2> type;

View file

@ -46,7 +46,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
count_n( count_n(
InputIterator first, typename std::iterator_traits<InputIterator>::difference_type n, T const& value, InputIterator first, typename std::iterator_traits<InputIterator>::difference_type n, T const& value,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;

View file

@ -46,7 +46,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
count_n_if( count_n_if(
InputIterator first, typename std::iterator_traits<InputIterator>::difference_type n, Predicate pred, InputIterator first, typename std::iterator_traits<InputIterator>::difference_type n, Predicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;

View file

@ -91,7 +91,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
overlap_count( overlap_count(
InputIterator first, InputIterator last, BinaryPredicate pred, InputIterator first, InputIterator last, BinaryPredicate pred,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type> type;

View file

@ -86,7 +86,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR ForwardIterator1 inline SPROUT_CONSTEXPR ForwardIterator1
search_one( search_one(
ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred,
void* std::forward_iterator_tag*
) )
{ {
typedef sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool> type; typedef sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool> type;

View file

@ -28,7 +28,7 @@ namespace sprout {
> >
{ {
public: public:
typedef Iterator base_type; typedef Iterator iterator_type;
typedef Traits traits_type; typedef Traits traits_type;
private: private:
typedef std::iterator< typedef std::iterator<
@ -37,34 +37,34 @@ namespace sprout {
std::ptrdiff_t, std::ptrdiff_t,
void, void,
unsigned char unsigned char
> iterator_type; > base_type;
public: public:
typedef typename iterator_type::iterator_category iterator_category; typedef typename base_type::iterator_category iterator_category;
typedef typename iterator_type::value_type value_type; typedef typename base_type::value_type value_type;
typedef typename iterator_type::difference_type difference_type; typedef typename base_type::difference_type difference_type;
typedef typename iterator_type::pointer pointer; typedef typename base_type::pointer pointer;
typedef typename iterator_type::reference reference; typedef typename base_type::reference reference;
private: private:
struct next_tag {}; struct next_tag {};
struct prev_tag {}; struct prev_tag {};
struct ra_tag {}; struct ra_tag {};
private: private:
base_type it_; iterator_type it_;
difference_type i_; difference_type i_;
private: private:
SPROUT_CONSTEXPR bytes_iterator(base_type it, difference_type i) SPROUT_CONSTEXPR bytes_iterator(iterator_type it, difference_type i)
: it_(it) : it_(it)
, i_(i) , i_(i)
{} {}
SPROUT_CONSTEXPR bytes_iterator(base_type it, difference_type i, next_tag) SPROUT_CONSTEXPR bytes_iterator(iterator_type it, difference_type i, next_tag)
: it_(i / traits_type::size() == 0 ? it : sprout::next(it)) : it_(i / traits_type::size() == 0 ? it : sprout::next(it))
, i_(i % traits_type::size()) , i_(i % traits_type::size())
{} {}
SPROUT_CONSTEXPR bytes_iterator(base_type it, difference_type i, prev_tag) SPROUT_CONSTEXPR bytes_iterator(iterator_type it, difference_type i, prev_tag)
: it_((i + 1 - traits_type::size()) / traits_type::size() == 0 ? it : sprout::prev(it)) : it_((i + 1 - traits_type::size()) / traits_type::size() == 0 ? it : sprout::prev(it))
, i_(i % traits_type::size() + traits_type::size()) , i_(i % traits_type::size() + traits_type::size())
{} {}
SPROUT_CONSTEXPR bytes_iterator(base_type it, difference_type i, ra_tag) SPROUT_CONSTEXPR bytes_iterator(iterator_type it, difference_type i, ra_tag)
: it_(i >= 0 : it_(i >= 0
? sprout::next(it, i / traits_type::size()) ? sprout::next(it, i / traits_type::size())
: sprout::next(it, (i + 1 - traits_type::size()) / traits_type::size()) : sprout::next(it, (i + 1 - traits_type::size()) / traits_type::size())
@ -76,14 +76,18 @@ namespace sprout {
{} {}
public: public:
SPROUT_CONSTEXPR bytes_iterator() SPROUT_CONSTEXPR bytes_iterator()
: it_() : it_(), i_()
, i_()
{} {}
bytes_iterator(bytes_iterator const&) = default; bytes_iterator(bytes_iterator const&) = default;
explicit SPROUT_CONSTEXPR bytes_iterator(base_type it) explicit SPROUT_CONSTEXPR bytes_iterator(iterator_type it)
: it_(it) : it_(it), i_()
, i_()
{} {}
SPROUT_CONSTEXPR iterator_type const& base() const {
return it_;
}
SPROUT_CONSTEXPR difference_type index() const {
return i_;
}
SPROUT_CONSTEXPR bytes_iterator next() const { SPROUT_CONSTEXPR bytes_iterator next() const {
return bytes_iterator(it_, i_ + 1, next_tag()); return bytes_iterator(it_, i_ + 1, next_tag());
} }
@ -96,24 +100,6 @@ namespace sprout {
sprout::swap(it_, other.it_); sprout::swap(it_, other.it_);
sprout::swap(i_, other.i_); sprout::swap(i_, other.i_);
} }
friend SPROUT_CONSTEXPR bool operator==(bytes_iterator const& lhs, bytes_iterator const& rhs) {
return lhs.it_ == rhs.it_ && lhs.i_ == rhs.i_;
}
friend SPROUT_CONSTEXPR bool operator!=(bytes_iterator const& lhs, bytes_iterator const& rhs) {
return !(lhs == rhs);
}
friend SPROUT_CONSTEXPR bool operator<(bytes_iterator const& lhs, bytes_iterator const& rhs) {
return lhs.it_ < rhs.it_ || (lhs.it_ == rhs.it_ && lhs.i_ < rhs.i_);
}
friend SPROUT_CONSTEXPR bool operator>(bytes_iterator const& lhs, bytes_iterator const& rhs) {
return rhs < lhs;
}
friend SPROUT_CONSTEXPR bool operator<=(bytes_iterator const& lhs, bytes_iterator const& rhs) {
return !(rhs < lhs);
}
friend SPROUT_CONSTEXPR bool operator>=(bytes_iterator const& lhs, bytes_iterator const& rhs) {
return !(lhs < rhs);
}
SPROUT_CONSTEXPR reference operator*() const { SPROUT_CONSTEXPR reference operator*() const {
return traits_type::get_byte(*it_, i_); return traits_type::get_byte(*it_, i_);
} }
@ -156,13 +142,59 @@ namespace sprout {
SPROUT_CONSTEXPR reference operator[](difference_type n) const { SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return *(*this + n); return *(*this + n);
} }
friend SPROUT_CONSTEXPR difference_type operator-(bytes_iterator const& lhs, bytes_iterator const& rhs) { };
return (lhs.it_ - rhs.it_) * traits_type::size() + (lhs.i_ - rhs.i_);
template<typename Iterator1, typename Iterator2, typename Traits>
inline SPROUT_CONSTEXPR bool
operator==(sprout::bytes_iterator<Iterator1, Traits> const& lhs, sprout::bytes_iterator<Iterator2, Traits> const& rhs) {
return lhs.base() == rhs.base() && lhs.index() == rhs.index();
} }
friend SPROUT_CONSTEXPR bytes_iterator operator+(difference_type n, bytes_iterator const& it) { template<typename Iterator1, typename Iterator2, typename Traits>
inline SPROUT_CONSTEXPR bool
operator!=(sprout::bytes_iterator<Iterator1, Traits> const& lhs, sprout::bytes_iterator<Iterator2, Traits> const& rhs) {
return !(lhs == rhs);
}
template<typename Iterator1, typename Iterator2, typename Traits>
inline SPROUT_CONSTEXPR bool
operator<(sprout::bytes_iterator<Iterator1, Traits> const& lhs, sprout::bytes_iterator<Iterator2, Traits> const& rhs) {
return lhs.base() < rhs.base() || (lhs.base() == rhs.base() && lhs.index() < rhs.index());
}
template<typename Iterator1, typename Iterator2, typename Traits>
inline SPROUT_CONSTEXPR bool
operator>(sprout::bytes_iterator<Iterator1, Traits> const& lhs, sprout::bytes_iterator<Iterator2, Traits> const& rhs) {
return rhs < lhs;
}
template<typename Iterator1, typename Iterator2, typename Traits>
inline SPROUT_CONSTEXPR bool
operator<=(sprout::bytes_iterator<Iterator1, Traits> const& lhs, sprout::bytes_iterator<Iterator2, Traits> const& rhs) {
return !(rhs < lhs);
}
template<typename Iterator1, typename Iterator2, typename Traits>
inline SPROUT_CONSTEXPR bool
operator>=(sprout::bytes_iterator<Iterator1, Traits> const& lhs, sprout::bytes_iterator<Iterator2, Traits> const& rhs) {
return !(lhs < rhs);
}
template<typename Iterator1, typename Iterator2, typename Traits>
inline SPROUT_CONSTEXPR decltype(std::declval<Iterator1>() - std::declval<Iterator2>())
operator-(sprout::bytes_iterator<Iterator1, Traits> const& lhs, sprout::bytes_iterator<Iterator2, Traits> const& rhs) {
return (lhs.base() - rhs.base()) * Traits::size() + (lhs.index() - rhs.index());
}
template<typename Iterator, typename Traits>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits>
operator+(typename sprout::bytes_iterator<Iterator, Traits>::difference_type n, sprout::bytes_iterator<Iterator, Traits> const& it) {
return it + n; return it + n;
} }
};
//
// swap
//
template<typename Iterator, typename Traits>
inline void
swap(sprout::bytes_iterator<Iterator, Traits>& lhs, sprout::bytes_iterator<Iterator, Traits>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))
{
lhs.swap(rhs);
}
// //
// make_bytes_iterator // make_bytes_iterator
@ -179,14 +211,18 @@ namespace sprout {
} }
// //
// swap // make_big_bytes_iterator
// make_little_bytes_iterator
// //
template<typename Iterator, typename Traits> template<typename Iterator>
inline void inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, sprout::big_endian_traits<typename std::iterator_traits<Iterator>::value_type> >
swap(sprout::bytes_iterator<Iterator, Traits>& lhs, sprout::bytes_iterator<Iterator, Traits>& rhs) make_big_bytes_iterator(Iterator it) {
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) return sprout::bytes_iterator<Iterator, sprout::big_endian_traits<typename std::iterator_traits<Iterator>::value_type> >(it);
{ }
lhs.swap(rhs); template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, sprout::little_endian_traits<typename std::iterator_traits<Iterator>::value_type> >
make_little_bytes_iterator(Iterator it) {
return sprout::bytes_iterator<Iterator, sprout::little_endian_traits<typename std::iterator_traits<Iterator>::value_type> >(it);
} }
// //

View file

@ -76,24 +76,6 @@ namespace sprout {
sprout::swap(index_, other.index_); sprout::swap(index_, other.index_);
sprout::swap(size_, other.size_); sprout::swap(size_, other.size_);
} }
friend SPROUT_CONSTEXPR bool operator==(dft_iterator const& lhs, dft_iterator const& rhs) {
return lhs.index_ == rhs.index_;
}
friend SPROUT_CONSTEXPR bool operator!=(dft_iterator const& lhs, dft_iterator const& rhs) {
return !(lhs == rhs);
}
friend SPROUT_CONSTEXPR bool operator<(dft_iterator const& lhs, dft_iterator const& rhs) {
return lhs.index_ < rhs.index_;
}
friend SPROUT_CONSTEXPR bool operator>(dft_iterator const& lhs, dft_iterator const& rhs) {
return rhs < lhs;
}
friend SPROUT_CONSTEXPR bool operator<=(dft_iterator const& lhs, dft_iterator const& rhs) {
return !(rhs < lhs);
}
friend SPROUT_CONSTEXPR bool operator>=(dft_iterator const& lhs, dft_iterator const& rhs) {
return !(lhs < rhs);
}
SPROUT_CONSTEXPR reference operator*() const { SPROUT_CONSTEXPR reference operator*() const {
return sprout::detail::dft_element_impl(first_, last_, index_, size_); return sprout::detail::dft_element_impl(first_, last_, index_, size_);
} }
@ -136,13 +118,48 @@ namespace sprout {
SPROUT_CONSTEXPR reference operator[](difference_type n) const { SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return sprout::detail::dft_element_impl(first_, last_, index_ + n, size_); return sprout::detail::dft_element_impl(first_, last_, index_ + n, size_);
} }
friend SPROUT_CONSTEXPR difference_type operator-(dft_iterator const& lhs, dft_iterator const& rhs) { };
return lhs.index_ - rhs.index_;
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator==(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
return lhs.index() == rhs.index();
} }
friend SPROUT_CONSTEXPR dft_iterator operator+(difference_type n, dft_iterator const& it) { template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator!=(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
return !(lhs == rhs);
}
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator<(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
return lhs.index_ < rhs.index_;
}
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator>(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
return rhs < lhs;
}
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator<=(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
return !(rhs < lhs);
}
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator>=(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
return !(lhs < rhs);
}
template<typename Iterator>
inline SPROUT_CONSTEXPR typename sprout::dft_iterator<Iterator>::difference_type
operator-(sprout::dft_iterator<Iterator> const& lhs, sprout::dft_iterator<Iterator> const& rhs) {
return lhs.index() - rhs.index();
}
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::dft_iterator<Iterator>
operator+(typename sprout::dft_iterator<Iterator>::difference_type n, sprout::dft_iterator<Iterator> const& it) {
return it + n; return it + n;
} }
};
// //
// make_dft_iterator // make_dft_iterator

View file

@ -63,7 +63,7 @@ namespace sprout {
} }
template<typename InputIterator> template<typename InputIterator>
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
iterator_distance(InputIterator first, InputIterator last, void*) { iterator_distance(InputIterator first, InputIterator last, std::input_iterator_tag*) {
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type; typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
return sprout::iterator_detail::iterator_distance_impl(type(first, 0), last, 1).second; return sprout::iterator_detail::iterator_distance_impl(type(first, 0), last, 1).second;
} }

View file

@ -5,7 +5,6 @@
#include <limits> #include <limits>
#include <iterator> #include <iterator>
#include <utility> #include <utility>
#include <stdexcept>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/generator/functions.hpp> #include <sprout/generator/functions.hpp>
@ -34,16 +33,16 @@ namespace sprout {
typedef value_type* pointer; typedef value_type* pointer;
private: private:
generator_type gen_; generator_type gen_;
difference_type count_; difference_type index_;
public: public:
SPROUT_CONSTEXPR generator_iterator() SPROUT_CONSTEXPR generator_iterator()
: gen_(), count_() : gen_(), index_()
{} {}
explicit SPROUT_CONSTEXPR generator_iterator( explicit SPROUT_CONSTEXPR generator_iterator(
generator_type const& gen, generator_type const& gen,
difference_type count = std::numeric_limits<difference_type>::max() difference_type index = std::numeric_limits<difference_type>::max()
) )
: gen_(gen), count_(count) : gen_(gen), index_(index)
{} {}
generator_type& generator() { generator_type& generator() {
return gen_; return gen_;
@ -51,14 +50,11 @@ namespace sprout {
SPROUT_CONSTEXPR generator_type const& generator() const { SPROUT_CONSTEXPR generator_type const& generator() const {
return gen_; return gen_;
} }
SPROUT_CONSTEXPR difference_type count() const { SPROUT_CONSTEXPR difference_type index() const {
return count_; return index_;
} }
SPROUT_CONSTEXPR generator_iterator operator()() const { SPROUT_CONSTEXPR generator_iterator operator()() const {
return count_ != 0 return generator_iterator(sprout::generators::next_generator(gen_)(), index_ - 1);
? generator_iterator(sprout::generators::next_generator(gen_)(), count_ > 0 ? count_ - 1 : count_)
: throw std::out_of_range("generator_iterator<>: increment at out of range")
;
} }
SPROUT_CONSTEXPR generator_iterator next() const { SPROUT_CONSTEXPR generator_iterator next() const {
return (*this)(); return (*this)();
@ -73,35 +69,10 @@ namespace sprout {
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(gen_, other.gen_))) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(gen_, other.gen_)))
{ {
sprout::swap(gen_, other.gen_); sprout::swap(gen_, other.gen_);
sprout::swap(count_, other.count_); sprout::swap(index_, other.index_);
}
friend SPROUT_CONSTEXPR bool operator==(generator_iterator const& lhs, generator_iterator const& rhs) {
return lhs.count_ == rhs.count_;
}
friend SPROUT_CONSTEXPR bool operator!=(generator_iterator const& lhs, generator_iterator const& rhs) {
return !(lhs == rhs);
}
friend SPROUT_CONSTEXPR bool operator<(generator_iterator const& lhs, generator_iterator const& rhs) {
typedef typename std::make_unsigned<difference_type>::type unsigned_type;
return static_cast<unsigned_type>(lhs.count_) > static_cast<unsigned_type>(rhs.count_);
}
friend SPROUT_CONSTEXPR bool operator>(generator_iterator const& lhs, generator_iterator const& rhs) {
return rhs < lhs;
}
friend SPROUT_CONSTEXPR bool operator<=(generator_iterator const& lhs, generator_iterator const& rhs) {
return !(rhs < lhs);
}
friend SPROUT_CONSTEXPR bool operator>=(generator_iterator const& lhs, generator_iterator const& rhs) {
return !(lhs < rhs);
} }
SPROUT_CONSTEXPR reference operator*() const { SPROUT_CONSTEXPR reference operator*() const {
return count_ != 0 return sprout::generators::generated_value(gen_);
? sprout::generators::generated_value(gen_)
: (
throw std::out_of_range("generator_iterator<>: dereference at out of range"),
sprout::generators::generated_value(gen_)
)
;
} }
SPROUT_CONSTEXPR pointer operator->() const { SPROUT_CONSTEXPR pointer operator->() const {
return &*(*this); return &*(*this);
@ -116,11 +87,44 @@ namespace sprout {
++*this; ++*this;
return result; return result;
} }
friend SPROUT_CONSTEXPR difference_type operator-(generator_iterator const& lhs, generator_iterator const& rhs) {
return rhs.count_ - lhs.count_;
}
}; };
template<typename Generator>
inline SPROUT_CONSTEXPR bool
operator==(sprout::generator_iterator<Generator> const& lhs, sprout::generator_iterator<Generator> const& rhs) {
return lhs.index() == rhs.index();
}
template<typename Generator>
inline SPROUT_CONSTEXPR bool
operator!=(sprout::generator_iterator<Generator> const& lhs, sprout::generator_iterator<Generator> const& rhs) {
return !(lhs == rhs);
}
template<typename Generator>
inline SPROUT_CONSTEXPR bool
operator<(sprout::generator_iterator<Generator> const& lhs, sprout::generator_iterator<Generator> const& rhs) {
return rhs.index() < lhs.index();
}
template<typename Generator>
inline SPROUT_CONSTEXPR bool
operator>(sprout::generator_iterator<Generator> const& lhs, sprout::generator_iterator<Generator> const& rhs) {
return rhs < lhs;
}
template<typename Generator>
inline SPROUT_CONSTEXPR bool
operator<=(sprout::generator_iterator<Generator> const& lhs, sprout::generator_iterator<Generator> const& rhs) {
return !(rhs < lhs);
}
template<typename Generator>
inline SPROUT_CONSTEXPR bool
operator>=(sprout::generator_iterator<Generator> const& lhs, sprout::generator_iterator<Generator> const& rhs) {
return !(lhs < rhs);
}
template<typename Generator>
inline SPROUT_CONSTEXPR typename sprout::generator_iterator<Generator>::difference_type
operator-(sprout::generator_iterator<Generator> const& lhs, sprout::generator_iterator<Generator> const& rhs) {
return rhs.index() - lhs.index();
}
// //
// swap // swap
// //

View file

@ -76,24 +76,6 @@ namespace sprout {
sprout::swap(index_, other.index_); sprout::swap(index_, other.index_);
sprout::swap(size_, other.size_); sprout::swap(size_, other.size_);
} }
friend SPROUT_CONSTEXPR bool operator==(idft_iterator const& lhs, idft_iterator const& rhs) {
return lhs.index_ == rhs.index_;
}
friend SPROUT_CONSTEXPR bool operator!=(idft_iterator const& lhs, idft_iterator const& rhs) {
return !(lhs == rhs);
}
friend SPROUT_CONSTEXPR bool operator<(idft_iterator const& lhs, idft_iterator const& rhs) {
return lhs.index_ < rhs.index_;
}
friend SPROUT_CONSTEXPR bool operator>(idft_iterator const& lhs, idft_iterator const& rhs) {
return rhs < lhs;
}
friend SPROUT_CONSTEXPR bool operator<=(idft_iterator const& lhs, idft_iterator const& rhs) {
return !(rhs < lhs);
}
friend SPROUT_CONSTEXPR bool operator>=(idft_iterator const& lhs, idft_iterator const& rhs) {
return !(lhs < rhs);
}
SPROUT_CONSTEXPR reference operator*() const { SPROUT_CONSTEXPR reference operator*() const {
return sprout::detail::idft_element_impl(first_, last_, index_, size_); return sprout::detail::idft_element_impl(first_, last_, index_, size_);
} }
@ -136,13 +118,48 @@ namespace sprout {
SPROUT_CONSTEXPR reference operator[](difference_type n) const { SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return sprout::detail::idft_element_impl(first_, last_, index_ + n, size_); return sprout::detail::idft_element_impl(first_, last_, index_ + n, size_);
} }
friend SPROUT_CONSTEXPR difference_type operator-(idft_iterator const& lhs, idft_iterator const& rhs) { };
return lhs.index_ - rhs.index_;
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator==(sprout::idft_iterator<Iterator> const& lhs, sprout::idft_iterator<Iterator> const& rhs) {
return lhs.index() == rhs.index();
} }
friend SPROUT_CONSTEXPR idft_iterator operator+(difference_type n, idft_iterator const& it) { template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator!=(sprout::idft_iterator<Iterator> const& lhs, sprout::idft_iterator<Iterator> const& rhs) {
return !(lhs == rhs);
}
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator<(sprout::idft_iterator<Iterator> const& lhs, sprout::idft_iterator<Iterator> const& rhs) {
return lhs.index_ < rhs.index_;
}
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator>(sprout::idft_iterator<Iterator> const& lhs, sprout::idft_iterator<Iterator> const& rhs) {
return rhs < lhs;
}
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator<=(sprout::idft_iterator<Iterator> const& lhs, sprout::idft_iterator<Iterator> const& rhs) {
return !(rhs < lhs);
}
template<typename Iterator>
inline SPROUT_CONSTEXPR bool
operator>=(sprout::idft_iterator<Iterator> const& lhs, sprout::idft_iterator<Iterator> const& rhs) {
return !(lhs < rhs);
}
template<typename Iterator>
inline SPROUT_CONSTEXPR typename sprout::idft_iterator<Iterator>::difference_type
operator-(sprout::idft_iterator<Iterator> const& lhs, sprout::idft_iterator<Iterator> const& rhs) {
return lhs.index() - rhs.index();
}
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::idft_iterator<Iterator>
operator+(typename sprout::idft_iterator<Iterator>::difference_type n, sprout::idft_iterator<Iterator> const& it) {
return it + n; return it + n;
} }
};
// //
// make_idft_iterator // make_idft_iterator

View file

@ -78,25 +78,21 @@ namespace sprout {
typedef typename traits_type::size_type size_type; typedef typename traits_type::size_type size_type;
private: private:
holder_type holder_; holder_type holder_;
size_type index_; difference_type index_;
private: private:
SPROUT_CONSTEXPR index_iterator(holder_type const& r, size_type index) SPROUT_CONSTEXPR index_iterator(holder_type const& r, difference_type index)
: holder_(r) : holder_(r), index_(index)
, index_(index)
{} {}
public: public:
SPROUT_CONSTEXPR index_iterator() SPROUT_CONSTEXPR index_iterator()
: holder_() : holder_(), index_()
, index_()
{} {}
index_iterator(index_iterator const&) = default; index_iterator(index_iterator const&) = default;
explicit SPROUT_CONSTEXPR index_iterator(typename holder_type::param_type p) explicit SPROUT_CONSTEXPR index_iterator(typename holder_type::param_type p)
: holder_(p) : holder_(p), index_(0)
, index_(0)
{} {}
SPROUT_CONSTEXPR index_iterator(typename holder_type::param_type p, size_type index) SPROUT_CONSTEXPR index_iterator(typename holder_type::param_type p, difference_type index)
: holder_(p) : holder_(p), index_(index)
, index_(index)
{} {}
operator index_iterator<const_container_type>() const { operator index_iterator<const_container_type>() const {
return index_iterator<const_container_type>(holder_.get(), index_); return index_iterator<const_container_type>(holder_.get(), index_);
@ -104,7 +100,7 @@ namespace sprout {
SPROUT_CONSTEXPR typename holder_type::mutable_or_const_reference base() const { SPROUT_CONSTEXPR typename holder_type::mutable_or_const_reference base() const {
return holder_.get(); return holder_.get();
} }
SPROUT_CONSTEXPR size_type index() const { SPROUT_CONSTEXPR difference_type index() const {
return index_; return index_;
} }
SPROUT_CONSTEXPR index_iterator next() const { SPROUT_CONSTEXPR index_iterator next() const {
@ -119,24 +115,6 @@ namespace sprout {
sprout::swap(holder_, other.holder_); sprout::swap(holder_, other.holder_);
sprout::swap(index_, other.index_); sprout::swap(index_, other.index_);
} }
friend SPROUT_CONSTEXPR bool operator==(index_iterator const& lhs, index_iterator const& rhs) {
return lhs.index_ == rhs.index_;
}
friend SPROUT_CONSTEXPR bool operator!=(index_iterator const& lhs, index_iterator const& rhs) {
return !(lhs == rhs);
}
friend SPROUT_CONSTEXPR bool operator<(index_iterator const& lhs, index_iterator const& rhs) {
return lhs.index_ < rhs.index_;
}
friend SPROUT_CONSTEXPR bool operator>(index_iterator const& lhs, index_iterator const& rhs) {
return rhs < lhs;
}
friend SPROUT_CONSTEXPR bool operator<=(index_iterator const& lhs, index_iterator const& rhs) {
return !(rhs < lhs);
}
friend SPROUT_CONSTEXPR bool operator>=(index_iterator const& lhs, index_iterator const& rhs) {
return !(lhs < rhs);
}
SPROUT_CONSTEXPR reference operator*() const { SPROUT_CONSTEXPR reference operator*() const {
return holder_.get()[index_]; return holder_.get()[index_];
} }
@ -182,13 +160,72 @@ namespace sprout {
SPROUT_CONSTEXPR reference operator[](difference_type n) const { SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return holder_.get()[index_ + n]; return holder_.get()[index_ + n];
} }
friend SPROUT_CONSTEXPR difference_type operator-(index_iterator const& lhs, index_iterator const& rhs) { };
return static_cast<difference_type>(lhs.index_) - static_cast<difference_type>(rhs.index_);
template<typename Container1, typename Container2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator==(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
return lhs.index() == rhs.index();
} }
friend SPROUT_CONSTEXPR index_iterator operator+(difference_type n, index_iterator const& it) { template<typename Container1, typename Container2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator!=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
return !(lhs == rhs);
}
template<typename Container1, typename Container2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator<(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
return lhs.index() < rhs.index();
}
template<typename Container1, typename Container2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator>(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
return rhs < lhs;
}
template<typename Container1, typename Container2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator<=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
return !(rhs < lhs);
}
template<typename Container1, typename Container2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
bool
>::type
operator>=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
return !(lhs < rhs);
}
template<typename Container1, typename Container2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
decltype(
std::declval<typename std::iterator_traits<sprout::index_iterator<Container1, C> >::difference_type>()
- std::declval<typename std::iterator_traits<sprout::index_iterator<Container2, C> >::difference_type>()
)
>::type
operator-(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
return lhs.index() - rhs.index();
}
template<typename Container, bool C>
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C>
operator+(typename sprout::index_iterator<Container, C>::difference_type n, sprout::index_iterator<Container, C> const& it) {
return it + n; return it + n;
} }
};
// //
// swap // swap

View file

@ -25,7 +25,7 @@ namespace sprout {
} }
template<typename ForwardIterator> template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator inline SPROUT_CONSTEXPR ForwardIterator
next_impl(ForwardIterator const& it, void*) { next_impl(ForwardIterator const& it, std::forward_iterator_tag*) {
return std::next(it); return std::next(it);
} }
@ -79,7 +79,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR ForwardIterator inline SPROUT_CONSTEXPR ForwardIterator
next_impl_1( next_impl_1(
ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n, ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n,
void* std::forward_iterator_tag*
) )
{ {
return n == 0 ? it return n == 0 ? it
@ -95,7 +95,7 @@ namespace sprout {
>::type >::type
next_impl( next_impl(
ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n, ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n,
void* std::forward_iterator_tag*
) )
{ {
typedef typename std::iterator_traits<ForwardIterator>::iterator_category* category; typedef typename std::iterator_traits<ForwardIterator>::iterator_category* category;
@ -108,7 +108,7 @@ namespace sprout {
>::type >::type
next_impl( next_impl(
ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n, ForwardIterator const& it, typename std::iterator_traits<ForwardIterator>::difference_type n,
void* std::forward_iterator_tag*
) )
{ {
return std::next(it, n); return std::next(it, n);

View file

@ -24,7 +24,7 @@ namespace sprout {
} }
template<typename BidirectionalIterator> template<typename BidirectionalIterator>
inline SPROUT_CONSTEXPR BidirectionalIterator inline SPROUT_CONSTEXPR BidirectionalIterator
prev_impl(BidirectionalIterator const& it, void*) { prev_impl(BidirectionalIterator const& it, std::bidirectional_iterator_tag*) {
return std::prev(it); return std::prev(it);
} }
@ -69,7 +69,7 @@ namespace sprout {
>::type >::type
prev_impl( prev_impl(
BidirectionalIterator const& it, typename std::iterator_traits<BidirectionalIterator>::difference_type n, BidirectionalIterator const& it, typename std::iterator_traits<BidirectionalIterator>::difference_type n,
void* std::bidirectional_iterator_tag*
) )
{ {
return n == 0 ? it return n == 0 ? it
@ -84,7 +84,7 @@ namespace sprout {
>::type >::type
prev_impl( prev_impl(
BidirectionalIterator const& it, typename std::iterator_traits<BidirectionalIterator>::difference_type n, BidirectionalIterator const& it, typename std::iterator_traits<BidirectionalIterator>::difference_type n,
void* std::bidirectional_iterator_tag*
) )
{ {
return std::prev(it, n); return std::prev(it, n);

View file

@ -52,17 +52,14 @@ namespace sprout {
difference_type index_; difference_type index_;
public: public:
SPROUT_CONSTEXPR ptr_index_iterator() SPROUT_CONSTEXPR ptr_index_iterator()
: p_() : p_(), index_()
, index_()
{} {}
ptr_index_iterator(ptr_index_iterator const&) = default; ptr_index_iterator(ptr_index_iterator const&) = default;
explicit SPROUT_CONSTEXPR ptr_index_iterator(pointer p) explicit SPROUT_CONSTEXPR ptr_index_iterator(pointer p)
: p_(p) : p_(p), index_(0)
, index_(0)
{} {}
SPROUT_CONSTEXPR ptr_index_iterator(pointer p, difference_type index) SPROUT_CONSTEXPR ptr_index_iterator(pointer p, difference_type index)
: p_(p) : p_(p), index_(index)
, index_(index)
{} {}
operator ptr_index_iterator<const_pointer>() const { operator ptr_index_iterator<const_pointer>() const {
return ptr_index_iterator<const_pointer>(p_, index_); return ptr_index_iterator<const_pointer>(p_, index_);
@ -88,24 +85,6 @@ namespace sprout {
sprout::swap(p_, other.p_); sprout::swap(p_, other.p_);
sprout::swap(index_, other.index_); sprout::swap(index_, other.index_);
} }
friend SPROUT_CONSTEXPR bool operator==(ptr_index_iterator const& lhs, ptr_index_iterator const& rhs) {
return lhs.index_ == rhs.index_;
}
friend SPROUT_CONSTEXPR bool operator!=(ptr_index_iterator const& lhs, ptr_index_iterator const& rhs) {
return !(lhs == rhs);
}
friend SPROUT_CONSTEXPR bool operator<(ptr_index_iterator const& lhs, ptr_index_iterator const& rhs) {
return lhs.index_ < rhs.index_;
}
friend SPROUT_CONSTEXPR bool operator>(ptr_index_iterator const& lhs, ptr_index_iterator const& rhs) {
return rhs < lhs;
}
friend SPROUT_CONSTEXPR bool operator<=(ptr_index_iterator const& lhs, ptr_index_iterator const& rhs) {
return !(rhs < lhs);
}
friend SPROUT_CONSTEXPR bool operator>=(ptr_index_iterator const& lhs, ptr_index_iterator const& rhs) {
return !(lhs < rhs);
}
SPROUT_CONSTEXPR reference operator*() const { SPROUT_CONSTEXPR reference operator*() const {
return p_[index_]; return p_[index_];
} }
@ -151,13 +130,72 @@ namespace sprout {
SPROUT_CONSTEXPR reference operator[](difference_type n) const { SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return p_[index_ + n]; return p_[index_ + n];
} }
friend SPROUT_CONSTEXPR difference_type operator-(ptr_index_iterator const& lhs, ptr_index_iterator const& rhs) { };
return lhs.index_ - rhs.index_;
template<typename T1, typename T2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<T1>::type, typename std::decay<T2>::type>::value,
bool
>::type
operator==(sprout::ptr_index_iterator<T1, C> const& lhs, sprout::ptr_index_iterator<T2, C> const& rhs) {
return lhs.index() == rhs.index();
} }
friend SPROUT_CONSTEXPR ptr_index_iterator operator+(difference_type n, ptr_index_iterator const& it) { template<typename T1, typename T2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<T1>::type, typename std::decay<T2>::type>::value,
bool
>::type
operator!=(sprout::ptr_index_iterator<T1, C> const& lhs, sprout::ptr_index_iterator<T2, C> const& rhs) {
return !(lhs == rhs);
}
template<typename T1, typename T2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<T1>::type, typename std::decay<T2>::type>::value,
bool
>::type
operator<(sprout::ptr_index_iterator<T1, C> const& lhs, sprout::ptr_index_iterator<T2, C> const& rhs) {
return lhs.index() < rhs.index();
}
template<typename T1, typename T2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<T1>::type, typename std::decay<T2>::type>::value,
bool
>::type
operator>(sprout::ptr_index_iterator<T1, C> const& lhs, sprout::ptr_index_iterator<T2, C> const& rhs) {
return rhs < lhs;
}
template<typename T1, typename T2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<T1>::type, typename std::decay<T2>::type>::value,
bool
>::type
operator<=(sprout::ptr_index_iterator<T1, C> const& lhs, sprout::ptr_index_iterator<T2, C> const& rhs) {
return !(rhs < lhs);
}
template<typename T1, typename T2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<T1>::type, typename std::decay<T2>::type>::value,
bool
>::type
operator>=(sprout::ptr_index_iterator<T1, C> const& lhs, sprout::ptr_index_iterator<T2, C> const& rhs) {
return !(lhs < rhs);
}
template<typename T1, typename T2, bool C>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_same<typename std::decay<T1>::type, typename std::decay<T2>::type>::value,
decltype(
std::declval<typename std::iterator_traits<sprout::ptr_index_iterator<T1, C> >::difference_type>()
- std::declval<typename std::iterator_traits<sprout::ptr_index_iterator<T2, C> >::difference_type>()
)
>::type
operator-(sprout::ptr_index_iterator<T1, C> const& lhs, sprout::ptr_index_iterator<T2, C> const& rhs) {
return lhs.index() - rhs.index();
}
template<typename T, bool C>
inline SPROUT_CONSTEXPR sprout::ptr_index_iterator<T, C>
operator+(typename sprout::ptr_index_iterator<T, C>::difference_type n, sprout::ptr_index_iterator<T, C> const& it) {
return it + n; return it + n;
} }
};
// //
// swap // swap

View file

@ -5,7 +5,6 @@
#include <limits> #include <limits>
#include <iterator> #include <iterator>
#include <utility> #include <utility>
#include <stdexcept>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/iterator/next.hpp> #include <sprout/iterator/next.hpp>
@ -51,66 +50,45 @@ namespace sprout {
typedef typename base_type::reference reference; typedef typename base_type::reference reference;
private: private:
sprout::value_holder<T> holder_; sprout::value_holder<T> holder_;
difference_type count_; difference_type index_;
private: private:
SPROUT_CONSTEXPR value_iterator(sprout::value_holder<T> const& r, difference_type count) SPROUT_CONSTEXPR value_iterator(sprout::value_holder<T> const& r, difference_type index)
: holder_(r), count_(count) : holder_(r), index_(index)
{} {}
public: public:
SPROUT_CONSTEXPR value_iterator() SPROUT_CONSTEXPR value_iterator()
: holder_(), count_() : holder_(), index_()
{} {}
value_iterator(value_iterator const&) = default; value_iterator(value_iterator const&) = default;
explicit SPROUT_CONSTEXPR value_iterator( explicit SPROUT_CONSTEXPR value_iterator(
typename sprout::value_holder<T>::param_type p, typename sprout::value_holder<T>::param_type p,
difference_type count = std::numeric_limits<difference_type>::max() difference_type index = std::numeric_limits<difference_type>::max()
) )
: holder_(p), count_(count) : holder_(p), index_(index)
{} {}
operator value_iterator<const_type>() const { operator value_iterator<const_type>() const {
return value_iterator<const_type>(holder_.get(), count_); return value_iterator<const_type>(holder_.get(), index_);
}
SPROUT_CONSTEXPR difference_type index() const {
return index_;
} }
SPROUT_CONSTEXPR value_iterator next() const { SPROUT_CONSTEXPR value_iterator next() const {
return value_iterator(holder_, count_ != 0 ? count_ - 1 : count_); return value_iterator(holder_, index_ - 1);
} }
SPROUT_CONSTEXPR value_iterator prev() const { SPROUT_CONSTEXPR value_iterator prev() const {
return value_iterator(holder_, count_ != 0 ? count_ + 1 : count_); return value_iterator(holder_, index_ + 1);
} }
void swap(value_iterator& other) void swap(value_iterator& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(holder_, other.holder_))) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(holder_, other.holder_)))
{ {
sprout::swap(holder_, other.holder_); sprout::swap(holder_, other.holder_);
sprout::swap(count_, other.count_); sprout::swap(index_, other.index_);
}
friend SPROUT_CONSTEXPR bool operator==(value_iterator const& lhs, value_iterator const& rhs) {
return lhs.count_ == rhs.count_ && (lhs.count_ == 0 || lhs.holder_.get() == rhs.holder_.get());
}
friend SPROUT_CONSTEXPR bool operator!=(value_iterator const& lhs, value_iterator const& rhs) {
return !(lhs == rhs);
}
friend SPROUT_CONSTEXPR bool operator<(value_iterator const& lhs, value_iterator const& rhs) {
return lhs.count_ > rhs.count_;
}
friend SPROUT_CONSTEXPR bool operator>(value_iterator const& lhs, value_iterator const& rhs) {
return rhs < lhs;
}
friend SPROUT_CONSTEXPR bool operator<=(value_iterator const& lhs, value_iterator const& rhs) {
return !(rhs < lhs);
}
friend SPROUT_CONSTEXPR bool operator>=(value_iterator const& lhs, value_iterator const& rhs) {
return !(lhs < rhs);
} }
SPROUT_CONSTEXPR reference operator*() const { SPROUT_CONSTEXPR reference operator*() const {
return count_ != 0 return holder_.get();
? holder_.get()
: (throw std::out_of_range("value_iterator<>: dereference at out of range"), holder_.get())
;
} }
SPROUT_CONSTEXPR pointer operator->() const { SPROUT_CONSTEXPR pointer operator->() const {
return count_ != 0 return holder_.get_pointer();
? holder_.get_pointer()
: throw std::out_of_range("value_iterator<>: dereference at out of range")
;
} }
value_iterator& operator++() { value_iterator& operator++() {
value_iterator temp(next()); value_iterator temp(next());
@ -133,31 +111,66 @@ namespace sprout {
return result; return result;
} }
SPROUT_CONSTEXPR value_iterator operator+(difference_type n) const { SPROUT_CONSTEXPR value_iterator operator+(difference_type n) const {
return value_iterator(holder_, count_ - n); return value_iterator(holder_, index_ - n);
} }
SPROUT_CONSTEXPR value_iterator operator-(difference_type n) const { SPROUT_CONSTEXPR value_iterator operator-(difference_type n) const {
return value_iterator(holder_, count_ + n); return value_iterator(holder_, index_ + n);
} }
value_iterator& operator+=(difference_type n) { value_iterator& operator+=(difference_type n) {
value_iterator temp(holder_, count_ - n); value_iterator temp(holder_, index_ - n);
temp.swap(*this); temp.swap(*this);
return *this; return *this;
} }
value_iterator& operator-=(difference_type n) { value_iterator& operator-=(difference_type n) {
value_iterator temp(holder_, count_ + n); value_iterator temp(holder_, index_ + n);
temp.swap(*this); temp.swap(*this);
return *this; return *this;
} }
SPROUT_CONSTEXPR reference operator[](difference_type n) const { SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return holder_.get(); return holder_.get();
} }
friend SPROUT_CONSTEXPR difference_type operator-(value_iterator const& lhs, value_iterator const& rhs) { };
return rhs.count_ - lhs.count_;
template<typename T>
inline SPROUT_CONSTEXPR bool
operator==(sprout::value_iterator<T> const& lhs, sprout::value_iterator<T> const& rhs) {
return lhs.index() == rhs.index();
} }
friend SPROUT_CONSTEXPR value_iterator operator+(difference_type n, value_iterator const& it) { template<typename T>
inline SPROUT_CONSTEXPR bool
operator!=(sprout::value_iterator<T> const& lhs, sprout::value_iterator<T> const& rhs) {
return !(lhs == rhs);
}
template<typename T>
inline SPROUT_CONSTEXPR bool
operator<(sprout::value_iterator<T> const& lhs, sprout::value_iterator<T> const& rhs) {
return rhs.index() < lhs.index();
}
template<typename T>
inline SPROUT_CONSTEXPR bool
operator>(sprout::value_iterator<T> const& lhs, sprout::value_iterator<T> const& rhs) {
return rhs < lhs;
}
template<typename T>
inline SPROUT_CONSTEXPR bool
operator<=(sprout::value_iterator<T> const& lhs, sprout::value_iterator<T> const& rhs) {
return !(rhs < lhs);
}
template<typename T>
inline SPROUT_CONSTEXPR bool
operator>=(sprout::value_iterator<T> const& lhs, sprout::value_iterator<T> const& rhs) {
return !(lhs < rhs);
}
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::value_iterator<T>::difference_type
operator-(sprout::value_iterator<T> const& lhs, sprout::value_iterator<T> const& rhs) {
return rhs.index() - lhs.index();
}
template<typename T>
inline SPROUT_CONSTEXPR sprout::value_iterator<T>
operator+(typename sprout::value_iterator<T>::difference_type n, sprout::value_iterator<T> const& it) {
return it + n; return it + n;
} }
};
// //
// swap // swap

View file

@ -90,7 +90,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR T inline SPROUT_CONSTEXPR T
accumulate( accumulate(
InputIterator first, InputIterator last, T init, BinaryOperation binary_op, InputIterator first, InputIterator last, T init, BinaryOperation binary_op,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::pair<InputIterator, T> type; typedef sprout::pair<InputIterator, T> type;

View file

@ -75,7 +75,7 @@ namespace sprout {
dft_element_gen_impl( dft_element_gen_impl(
InputIterator first, InputIterator last, InputIterator first, InputIterator last,
typename std::iterator_traits<InputIterator>::value_type::value_type arg, typename std::iterator_traits<InputIterator>::value_type::value_type arg,
void* std::input_iterator_tag*
) )
{ {
return sprout::detail::dft_element_gen_impl_1(first, last, arg); return sprout::detail::dft_element_gen_impl_1(first, last, arg);

View file

@ -88,7 +88,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
amplitude_spectrum( amplitude_spectrum(
ForwardIterator first, ForwardIterator last, Result const& result, ForwardIterator first, ForwardIterator last, Result const& result,
void* std::forward_iterator_tag*
) )
{ {
return sprout::fixed::detail::amplitude_spectrum_impl(first, last, result, sprout::size(result)); return sprout::fixed::detail::amplitude_spectrum_impl(first, last, result, sprout::size(result));

View file

@ -90,7 +90,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
dft( dft(
ForwardIterator first, ForwardIterator last, Result const& result, ForwardIterator first, ForwardIterator last, Result const& result,
void* std::forward_iterator_tag*
) )
{ {
return sprout::fixed::detail::dft_impl(first, last, result, sprout::size(result), first, 0); return sprout::fixed::detail::dft_impl(first, last, result, sprout::size(result), first, 0);

View file

@ -90,7 +90,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
idft( idft(
ForwardIterator first, ForwardIterator last, Result const& result, ForwardIterator first, ForwardIterator last, Result const& result,
void* std::forward_iterator_tag*
) )
{ {
return sprout::fixed::detail::idft_impl(first, last, result, sprout::size(result), first, 0); return sprout::fixed::detail::idft_impl(first, last, result, sprout::size(result), first, 0);

View file

@ -88,7 +88,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
phase_spectrum( phase_spectrum(
ForwardIterator first, ForwardIterator last, Result const& result, ForwardIterator first, ForwardIterator last, Result const& result,
void* std::forward_iterator_tag*
) )
{ {
return sprout::fixed::detail::phase_spectrum_impl(first, last, result, sprout::size(result)); return sprout::fixed::detail::phase_spectrum_impl(first, last, result, sprout::size(result));

View file

@ -99,7 +99,7 @@ namespace sprout {
inner_product( inner_product(
InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init,
BinaryOperation1 binary_op1, BinaryOperation2 binary_op2, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2,
void* std::input_iterator_tag*
) )
{ {
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, T> type; typedef sprout::tuples::tuple<InputIterator1, InputIterator2, T> type;

View file

@ -8,6 +8,7 @@
#include <sprout/type_traits/is_c_str.hpp> #include <sprout/type_traits/is_c_str.hpp>
#include <sprout/type_traits/lvalue_reference.hpp> #include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/type_traits/const_reference.hpp> #include <sprout/type_traits/const_reference.hpp>
#include <sprout/type_traits/common_decay.hpp>
#include <sprout/type_traits/arithmetic_promote.hpp> #include <sprout/type_traits/arithmetic_promote.hpp>
#include <sprout/type_traits/float_promote.hpp> #include <sprout/type_traits/float_promote.hpp>
#include <sprout/type_traits/enabler_if.hpp> #include <sprout/type_traits/enabler_if.hpp>

View file

@ -0,0 +1,17 @@
#ifndef SPROUT_TYPE_TRAITS_COMMON_DECAY_HPP
#define SPROUT_TYPE_TRAITS_COMMON_DECAY_HPP
#include <type_traits>
#include <sprout/config.hpp>
namespace sprout {
//
// common_decay
//
template<typename... Types>
struct common_decay
: public std::decay<typename std::common_type<Types...>::type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_COMMON_DECAY_HPP