From 092910e2f7feee7d1d0c16709f2c0fca7a28ba49 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Thu, 31 Jan 2013 23:25:18 +0900 Subject: [PATCH] add iterator category check for algorithm incomplete implementation --- sprout/algorithm/adjacent_find.hpp | 4 +- sprout/algorithm/fit/clamp_range_copy.hpp | 5 ++- sprout/algorithm/fit/copy.hpp | 4 +- sprout/algorithm/fit/copy_backward.hpp | 2 +- sprout/algorithm/fit/copy_if.hpp | 2 + sprout/algorithm/fit/copy_until.hpp | 9 ++-- sprout/algorithm/fit/copy_while.hpp | 7 ++- sprout/algorithm/fit/make_partial_heap.hpp | 2 +- sprout/algorithm/fit/merge.hpp | 11 ++++- sprout/algorithm/fit/nth_element.hpp | 2 +- sprout/algorithm/fit/partial_sort.hpp | 2 +- sprout/algorithm/fit/partition_copy.hpp | 7 +-- sprout/algorithm/fit/remove_copy.hpp | 4 +- sprout/algorithm/fit/remove_copy_if.hpp | 4 +- sprout/algorithm/fit/replace_copy.hpp | 8 +++- sprout/algorithm/fit/replace_copy_if.hpp | 4 +- sprout/algorithm/fit/reverse_copy.hpp | 2 +- sprout/algorithm/fit/rotate_copy.hpp | 2 +- sprout/algorithm/fit/set_difference.hpp | 13 +++++- sprout/algorithm/fit/set_intersection.hpp | 11 ++++- .../fit/set_symmetric_difference.hpp | 16 +++++-- sprout/algorithm/fit/set_union.hpp | 17 ++++--- .../algorithm/fit/stable_partition_copy.hpp | 2 + sprout/algorithm/fit/transform.hpp | 21 +++++---- sprout/algorithm/fit/unique_copy.hpp | 5 ++- sprout/algorithm/fixed/copy_n.hpp | 14 ++---- sprout/algorithm/fixed/unique_copy.hpp | 44 ++++++------------- sprout/algorithm/is_sorted_until.hpp | 4 +- sprout/cstring/strchr.hpp | 2 +- 29 files changed, 139 insertions(+), 91 deletions(-) diff --git a/sprout/algorithm/adjacent_find.hpp b/sprout/algorithm/adjacent_find.hpp index 1d514af8..2cf86c1f 100644 --- a/sprout/algorithm/adjacent_find.hpp +++ b/sprout/algorithm/adjacent_find.hpp @@ -67,7 +67,7 @@ namespace sprout { ; } template - inline SPROUT_CONSTEXPR sprout::pair + inline SPROUT_CONSTEXPR sprout::pair adjacent_find_impl_1( sprout::pair const& current, ForwardIterator last, BinaryPredicate pred, typename std::iterator_traits::difference_type n @@ -88,7 +88,7 @@ namespace sprout { ; } template - inline SPROUT_CONSTEXPR sprout::pair + inline SPROUT_CONSTEXPR sprout::pair adjacent_find_impl( sprout::pair const& current, ForwardIterator last, BinaryPredicate pred, typename std::iterator_traits::difference_type n diff --git a/sprout/algorithm/fit/clamp_range_copy.hpp b/sprout/algorithm/fit/clamp_range_copy.hpp index 608512ba..f41036f5 100644 --- a/sprout/algorithm/fit/clamp_range_copy.hpp +++ b/sprout/algorithm/fit/clamp_range_copy.hpp @@ -2,13 +2,14 @@ #define SPROUT_ALGORITHM_FIT_CLAMP_RANGE_COPY_HPP #include +#include #include #include #include #include #include -#include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT +#include namespace sprout { namespace fit { @@ -42,6 +43,7 @@ namespace sprout { Compare comp ) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::clamp_range_copy_impl(first, last, result, low, high, comp, sprout::internal_begin_offset(result)); } @@ -73,6 +75,7 @@ namespace sprout { typename std::iterator_traits::value_type const& high ) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::clamp_range_copy_impl(first, last, result, low, high, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/copy.hpp b/sprout/algorithm/fit/copy.hpp index 8df8b190..f1ccacd4 100644 --- a/sprout/algorithm/fit/copy.hpp +++ b/sprout/algorithm/fit/copy.hpp @@ -2,13 +2,14 @@ #define SPROUT_ALGORITHM_FIT_COPY_HPP #include +#include #include #include #include #include #include -#include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT +#include namespace sprout { namespace fit { @@ -33,6 +34,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type copy(InputIterator first, InputIterator last, Result const& result) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::copy_impl(first, last, result, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/copy_backward.hpp b/sprout/algorithm/fit/copy_backward.hpp index 57fcc92f..2493ef0a 100644 --- a/sprout/algorithm/fit/copy_backward.hpp +++ b/sprout/algorithm/fit/copy_backward.hpp @@ -2,13 +2,13 @@ #define SPROUT_ALGORITHM_FIT_COPY_BACKWARD_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/copy_if.hpp b/sprout/algorithm/fit/copy_if.hpp index ee2f2078..a1842d74 100644 --- a/sprout/algorithm/fit/copy_if.hpp +++ b/sprout/algorithm/fit/copy_if.hpp @@ -8,6 +8,7 @@ #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT +#include namespace sprout { namespace fit { @@ -32,6 +33,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type copy_if(InputIterator first, InputIterator last, Result const& result, Predicate pred) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::copy_if_impl(first, last, result, pred, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/copy_until.hpp b/sprout/algorithm/fit/copy_until.hpp index 2631d5e7..9e3b2653 100644 --- a/sprout/algorithm/fit/copy_until.hpp +++ b/sprout/algorithm/fit/copy_until.hpp @@ -2,13 +2,15 @@ #define SPROUT_ALGORITHM_FIT_COPY_UNTIL_HPP #include +#include #include #include -#include +#include #include +#include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -24,7 +26,7 @@ namespace sprout { sprout::get_internal(sprout::fixed::copy_until(first, last, result, pred)), offset, offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, NS_SSCRISK_CEL_OR_SPROUT::find_if(first, last, pred)), + sprout::distance(first, sprout::find_if(first, last, pred)), sprout::size(result) ) ); @@ -36,6 +38,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type copy_until(InputIterator first, InputIterator last, Result const& result, Predicate pred) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::copy_until_impl(first, last, result, pred, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/copy_while.hpp b/sprout/algorithm/fit/copy_while.hpp index 39a7d2f0..c56fc527 100644 --- a/sprout/algorithm/fit/copy_while.hpp +++ b/sprout/algorithm/fit/copy_while.hpp @@ -2,13 +2,15 @@ #define SPROUT_ALGORITHM_FIT_COPY_WHILE_HPP #include +#include #include #include #include #include +#include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -24,7 +26,7 @@ namespace sprout { sprout::get_internal(sprout::fixed::copy_while(first, last, result, pred)), offset, offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, NS_SSCRISK_CEL_OR_SPROUT::find_if_not(first, last, pred)), + sprout::distance(first, sprout::find_if_not(first, last, pred)), sprout::size(result) ) ); @@ -36,6 +38,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type copy_while(InputIterator first, InputIterator last, Result const& result, Predicate pred) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::copy_while_impl(first, last, result, pred, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/make_partial_heap.hpp b/sprout/algorithm/fit/make_partial_heap.hpp index 98d5f8d9..d72b853d 100644 --- a/sprout/algorithm/fit/make_partial_heap.hpp +++ b/sprout/algorithm/fit/make_partial_heap.hpp @@ -2,12 +2,12 @@ #define SPROUT_ALGORITHM_FIT_MAKE_PARTIAL_HEAP_HPP #include +#include #include #include #include #include #include -#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/merge.hpp b/sprout/algorithm/fit/merge.hpp index 7d36d3b1..86087b19 100644 --- a/sprout/algorithm/fit/merge.hpp +++ b/sprout/algorithm/fit/merge.hpp @@ -2,13 +2,14 @@ #define SPROUT_ALGORITHM_FIT_MERGE_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -43,6 +44,10 @@ namespace sprout { Result const& result, Compare comp ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::merge_impl(first1, last1, first2, last2, result, comp, sprout::internal_begin_offset(result)); } @@ -77,6 +82,10 @@ namespace sprout { Result const& result ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::merge_impl(first1, last1, first2, last2, result, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/nth_element.hpp b/sprout/algorithm/fit/nth_element.hpp index b40317d3..94fcef3d 100644 --- a/sprout/algorithm/fit/nth_element.hpp +++ b/sprout/algorithm/fit/nth_element.hpp @@ -2,12 +2,12 @@ #define SPROUT_ALGORITHM_FIT_NTH_ELEMENT_HPP #include +#include #include #include #include #include #include -#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/partial_sort.hpp b/sprout/algorithm/fit/partial_sort.hpp index 85ab5928..94a5a622 100644 --- a/sprout/algorithm/fit/partial_sort.hpp +++ b/sprout/algorithm/fit/partial_sort.hpp @@ -2,12 +2,12 @@ #define SPROUT_ALGORITHM_FIT_PARTIAL_SORT_HPP #include +#include #include #include #include #include #include -#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/partition_copy.hpp b/sprout/algorithm/fit/partition_copy.hpp index 68c06888..c7dd7b51 100644 --- a/sprout/algorithm/fit/partition_copy.hpp +++ b/sprout/algorithm/fit/partition_copy.hpp @@ -2,15 +2,16 @@ #define SPROUT_ALGORITHM_FIT_PARTITION_COPY_HPP #include +#include #include #include #include #include #include #include -#include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT +#include namespace sprout { namespace fit { @@ -28,8 +29,7 @@ namespace sprout { offset + sprout::detail::count_n_if( first, NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, last), - sprout::size(result) + sprout::distance(first, last), sprout::size(result) ), pred ) @@ -42,6 +42,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type partition_copy(InputIterator first, InputIterator last, Result const& result, Predicate pred) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::partition_copy_impl(first, last, result, pred, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/remove_copy.hpp b/sprout/algorithm/fit/remove_copy.hpp index 35095bfd..9ea33a28 100644 --- a/sprout/algorithm/fit/remove_copy.hpp +++ b/sprout/algorithm/fit/remove_copy.hpp @@ -2,13 +2,14 @@ #define SPROUT_ALGORITHM_FIT_REMOVE_COPY_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -36,6 +37,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type remove_copy(InputIterator first, InputIterator last, Result const& result, T const& value) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::remove_copy_impl(first, last, result, value, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/remove_copy_if.hpp b/sprout/algorithm/fit/remove_copy_if.hpp index 336c1aa2..9ab14332 100644 --- a/sprout/algorithm/fit/remove_copy_if.hpp +++ b/sprout/algorithm/fit/remove_copy_if.hpp @@ -2,13 +2,14 @@ #define SPROUT_ALGORITHM_FIT_REMOVE_COPY_IF_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -36,6 +37,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type remove_copy_if(InputIterator first, InputIterator last, Result const& result, Predicate pred) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::remove_copy_if_impl(first, last, result, pred, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/replace_copy.hpp b/sprout/algorithm/fit/replace_copy.hpp index f70e531c..654ee7ef 100644 --- a/sprout/algorithm/fit/replace_copy.hpp +++ b/sprout/algorithm/fit/replace_copy.hpp @@ -2,13 +2,14 @@ #define SPROUT_ALGORITHM_FIT_REPLACE_COPY_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -33,7 +34,10 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type replace_copy(InputIterator first, InputIterator last, Result const& result, T const& old_value, T const& new_value) { - return sprout::fit::detail::replace_copy_impl(first, last, result, old_value, new_value, sprout::internal_begin_offset(result)); + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); + return sprout::fit::detail::replace_copy_impl( + first, last, result, old_value, new_value, sprout::internal_begin_offset(result) + ); } } // namespace fit } // namespace sprout diff --git a/sprout/algorithm/fit/replace_copy_if.hpp b/sprout/algorithm/fit/replace_copy_if.hpp index 0d95fe21..0b466e38 100644 --- a/sprout/algorithm/fit/replace_copy_if.hpp +++ b/sprout/algorithm/fit/replace_copy_if.hpp @@ -2,13 +2,14 @@ #define SPROUT_ALGORITHM_FIT_REPLACE_COPY_IF_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -33,6 +34,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type replace_copy_if(InputIterator first, InputIterator last, Result const& result, Predicate pred, T const& new_value) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::replace_copy_if_impl(first, last, result, pred, new_value, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/reverse_copy.hpp b/sprout/algorithm/fit/reverse_copy.hpp index e8393b25..d7129815 100644 --- a/sprout/algorithm/fit/reverse_copy.hpp +++ b/sprout/algorithm/fit/reverse_copy.hpp @@ -2,13 +2,13 @@ #define SPROUT_ALGORITHM_FIT_REVERSE_COPY_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/rotate_copy.hpp b/sprout/algorithm/fit/rotate_copy.hpp index b0c392b0..e829c5f4 100644 --- a/sprout/algorithm/fit/rotate_copy.hpp +++ b/sprout/algorithm/fit/rotate_copy.hpp @@ -2,13 +2,13 @@ #define SPROUT_ALGORITHM_FIT_ROTATE_COPY_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/set_difference.hpp b/sprout/algorithm/fit/set_difference.hpp index e6cadede..89dc39ba 100644 --- a/sprout/algorithm/fit/set_difference.hpp +++ b/sprout/algorithm/fit/set_difference.hpp @@ -2,14 +2,15 @@ #define SPROUT_ALGORITHM_FIT_SET_DIFFERENCE_HPP #include +#include #include #include -#include +#include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -46,6 +47,10 @@ namespace sprout { Result const& result, Compare comp ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::set_difference_impl(first1, last1, first2, last2, result, comp, sprout::internal_begin_offset(result)); } @@ -82,6 +87,10 @@ namespace sprout { Result const& result ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::set_difference_impl(first1, last1, first2, last2, result, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/set_intersection.hpp b/sprout/algorithm/fit/set_intersection.hpp index 674aa5ac..8e108f16 100644 --- a/sprout/algorithm/fit/set_intersection.hpp +++ b/sprout/algorithm/fit/set_intersection.hpp @@ -4,11 +4,12 @@ #include #include #include -#include +#include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT +#include namespace sprout { namespace fit { @@ -43,6 +44,10 @@ namespace sprout { Result const& result, Compare comp ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::set_intersection_impl(first1, last1, first2, last2, result, comp, sprout::internal_begin_offset(result)); } @@ -77,6 +82,10 @@ namespace sprout { Result const& result ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::set_intersection_impl(first1, last1, first2, last2, result, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/set_symmetric_difference.hpp b/sprout/algorithm/fit/set_symmetric_difference.hpp index 1498ae5c..5d3e6a8e 100644 --- a/sprout/algorithm/fit/set_symmetric_difference.hpp +++ b/sprout/algorithm/fit/set_symmetric_difference.hpp @@ -2,14 +2,15 @@ #define SPROUT_ALGORITHM_FIT_SET_SYMMETRIC_DIFFERENCE_HPP #include +#include #include #include -#include +#include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -27,8 +28,7 @@ namespace sprout { sprout::get_internal(sprout::fixed::set_symmetric_difference(first1, last1, first2, last2, result, comp)), offset, offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first1, last1) - + sprout::distance(first2, last2) + sprout::distance(first1, last1) + sprout::distance(first2, last2) - 2 * sprout::detail::set_overlap_count(first1, last1, first2, last2, comp) , sprout::size(result) @@ -47,6 +47,10 @@ namespace sprout { Result const& result, Compare comp ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::set_symmetric_difference_impl(first1, last1, first2, last2, result, comp, sprout::internal_begin_offset(result)); } @@ -84,6 +88,10 @@ namespace sprout { Result const& result ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::set_symmetric_difference_impl(first1, last1, first2, last2, result, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/set_union.hpp b/sprout/algorithm/fit/set_union.hpp index 1c7c7626..cca1db1d 100644 --- a/sprout/algorithm/fit/set_union.hpp +++ b/sprout/algorithm/fit/set_union.hpp @@ -2,6 +2,7 @@ #define SPROUT_ALGORITHM_FIT_SET_UNION_HPP #include +#include #include #include #include @@ -9,7 +10,7 @@ #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -27,8 +28,7 @@ namespace sprout { sprout::get_internal(sprout::fixed::set_union(first1, last1, first2, last2, result, comp)), offset, offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first1, last1) - + sprout::distance(first2, last2) + sprout::distance(first1, last1) + sprout::distance(first2, last2) - sprout::detail::set_overlap_count(first1, last1, first2, last2, comp) , sprout::size(result) @@ -47,6 +47,10 @@ namespace sprout { Result const& result, Compare comp ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::set_union_impl(first1, last1, first2, last2, result, comp, sprout::internal_begin_offset(result)); } @@ -64,8 +68,7 @@ namespace sprout { sprout::get_internal(sprout::fixed::set_union(first1, last1, first2, last2, result)), offset, offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first1, last1) - + sprout::distance(first2, last2) + sprout::distance(first1, last1) + sprout::distance(first2, last2) - sprout::detail::set_overlap_count(first1, last1, first2, last2) , sprout::size(result) @@ -84,6 +87,10 @@ namespace sprout { Result const& result ) { + static_assert( + sprout::is_forward_iterator::value && sprout::is_forward_iterator::value, + "Sorry, not implemented." + ); return sprout::fit::detail::set_union_impl(first1, last1, first2, last2, result, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/stable_partition_copy.hpp b/sprout/algorithm/fit/stable_partition_copy.hpp index 89d9e304..645b7e45 100644 --- a/sprout/algorithm/fit/stable_partition_copy.hpp +++ b/sprout/algorithm/fit/stable_partition_copy.hpp @@ -8,6 +8,7 @@ #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT +#include namespace sprout { namespace fit { @@ -32,6 +33,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type stable_partition_copy(InputIterator first, InputIterator last, Result const& result, Predicate pred) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::stable_partition_copy_impl(first, last, result, pred, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/transform.hpp b/sprout/algorithm/fit/transform.hpp index 50fa0b22..6b7ac1f4 100644 --- a/sprout/algorithm/fit/transform.hpp +++ b/sprout/algorithm/fit/transform.hpp @@ -2,21 +2,22 @@ #define SPROUT_ALGORITHM_FIT_TRANSFORM_HPP #include +#include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { namespace detail { - template + template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type transform_impl( - Iterator first, Iterator last, Result const& result, UnaryOperation op, + InputIterator first, InputIterator last, Result const& result, UnaryOperation op, typename sprout::container_traits::difference_type offset ) { @@ -30,17 +31,18 @@ namespace sprout { // // transform // - template + template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type - transform(Iterator first, Iterator last, Result const& result, UnaryOperation op) { + transform(InputIterator first, InputIterator last, Result const& result, UnaryOperation op) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::transform_impl(first, last, result, op, sprout::internal_begin_offset(result)); } namespace detail { - template + template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type transform_impl( - Iterator1 first1, Iterator1 last1, Iterator2 first2, Result const& result, BinaryOperation op, + InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Result const& result, BinaryOperation op, typename sprout::container_traits::difference_type offset ) { @@ -54,9 +56,10 @@ namespace sprout { // // transform // - template + template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type - transform(Iterator1 first1, Iterator1 last1, Iterator2 first2, Result const& result, BinaryOperation op) { + transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Result const& result, BinaryOperation op) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::transform_impl(first1, last1, first2, result, op, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fit/unique_copy.hpp b/sprout/algorithm/fit/unique_copy.hpp index 94379bca..f19c415d 100644 --- a/sprout/algorithm/fit/unique_copy.hpp +++ b/sprout/algorithm/fit/unique_copy.hpp @@ -2,6 +2,7 @@ #define SPROUT_ALGORITHM_FIT_UNIQUE_COPY_HPP #include +#include #include #include #include @@ -9,7 +10,7 @@ #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { @@ -37,6 +38,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type unique_copy(InputIterator first, InputIterator last, Result const& result) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::unique_copy_impl(first, last, result, sprout::internal_begin_offset(result)); } @@ -64,6 +66,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm::type unique_copy(InputIterator first, InputIterator last, Result const& result, BinaryPredicate pred) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); return sprout::fit::detail::unique_copy_impl(first, last, result, pred, sprout::internal_begin_offset(result)); } } // namespace fit diff --git a/sprout/algorithm/fixed/copy_n.hpp b/sprout/algorithm/fixed/copy_n.hpp index 41ab10c2..d5b203fc 100644 --- a/sprout/algorithm/fixed/copy_n.hpp +++ b/sprout/algorithm/fixed/copy_n.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace sprout { namespace fixed { @@ -74,23 +75,14 @@ namespace sprout { return sprout::fixed::detail::copy_n(first, n, result, category()); } - template - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy_n_dyn( - ForwardIterator first, Size n, Result const& result, - std::forward_iterator_tag* - ) - { - return sprout::fixed::copy(first, sprout::next(first, n), result); - } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::is_fixed_container::value, typename sprout::fixed::result_of::algorithm::type >::type copy_n(InputIterator first, Size n, Result const& result) { - typedef typename std::iterator_traits::iterator_category* category; - return sprout::fixed::detail::copy_n_dyn(first, n, result, category()); + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); + return sprout::fixed::copy(first, sprout::next(first, n), result); } } // namespace detail // diff --git a/sprout/algorithm/fixed/unique_copy.hpp b/sprout/algorithm/fixed/unique_copy.hpp index 87d6b43c..4967ee1e 100644 --- a/sprout/algorithm/fixed/unique_copy.hpp +++ b/sprout/algorithm/fixed/unique_copy.hpp @@ -1,7 +1,6 @@ #ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP #define SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP -#include #include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include namespace sprout { namespace fixed { @@ -63,27 +63,18 @@ namespace sprout { ; } - template - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - unique_copy_dyn( - InputIterator first, InputIterator last, Result const& result, - std::forward_iterator_tag* - ) - { - return sprout::remake( - result, sprout::size(result), - sprout::make_unique_iterator(first, last), - sprout::make_unique_iterator(last, last) - ); - } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::is_fixed_container::value, typename sprout::fixed::result_of::algorithm::type >::type unique_copy(InputIterator first, InputIterator last, Result const& result) { - typedef typename std::iterator_traits::iterator_category* category; - return sprout::fixed::detail::unique_copy_dyn(first, last, result, category()); + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); + return sprout::remake( + result, sprout::size(result), + sprout::make_unique_iterator(first, last), + sprout::make_unique_iterator(last, last) + ); } } // namespace detail // @@ -150,27 +141,18 @@ namespace sprout { ; } - template - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - unique_copy_dyn( - InputIterator first, InputIterator last, Result const& result, BinaryPredicate pred, - std::forward_iterator_tag* - ) - { - return sprout::remake( - result, sprout::size(result), - sprout::make_unique_iterator(pred, first, last), - sprout::make_unique_iterator(pred, last, last) - ); - } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::is_fixed_container::value, typename sprout::fixed::result_of::algorithm::type >::type unique_copy(InputIterator first, InputIterator last, Result const& result, BinaryPredicate pred) { - typedef typename std::iterator_traits::iterator_category* category; - return sprout::fixed::detail::unique_copy_dyn(first, last, result, pred, category()); + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); + return sprout::remake( + result, sprout::size(result), + sprout::make_unique_iterator(pred, first, last), + sprout::make_unique_iterator(pred, last, last) + ); } } // namespace detail // diff --git a/sprout/algorithm/is_sorted_until.hpp b/sprout/algorithm/is_sorted_until.hpp index cd33727d..283f85ca 100644 --- a/sprout/algorithm/is_sorted_until.hpp +++ b/sprout/algorithm/is_sorted_until.hpp @@ -52,7 +52,7 @@ namespace sprout { } template - inline SPROUT_CONSTEXPR sprout::pair + inline SPROUT_CONSTEXPR sprout::pair is_sorted_until_impl_1( sprout::pair const& current, ForwardIterator last, Compare comp, typename std::iterator_traits::difference_type n @@ -73,7 +73,7 @@ namespace sprout { ; } template - inline SPROUT_CONSTEXPR sprout::pair + inline SPROUT_CONSTEXPR sprout::pair is_sorted_until_impl( sprout::pair const& current, ForwardIterator last, Compare comp, typename std::iterator_traits::difference_type n diff --git a/sprout/cstring/strchr.hpp b/sprout/cstring/strchr.hpp index be629a80..c25f4803 100644 --- a/sprout/cstring/strchr.hpp +++ b/sprout/cstring/strchr.hpp @@ -24,7 +24,7 @@ namespace sprout { : sprout::detail::strchr_impl_1( sprout::detail::strchr_impl_1( current, - value, n / 2 + value, n / 2 ), value, n - n / 2 )