From 74e83e31a7481e67d0a7005a98a97e1842fb9cd5 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Tue, 26 Feb 2013 10:43:27 +0900 Subject: [PATCH] add back_inserter, front_inserter --- sprout/algorithm/fit.hpp | 2 + sprout/algorithm/fit/clamp_range_copy.hpp | 5 +- sprout/algorithm/fit/copy.hpp | 3 +- sprout/algorithm/fit/copy_backward.hpp | 3 +- sprout/algorithm/fit/copy_if.hpp | 4 +- sprout/algorithm/fit/copy_n.hpp | 3 +- sprout/algorithm/fit/copy_until.hpp | 8 +- sprout/algorithm/fit/copy_while.hpp | 8 +- sprout/algorithm/fit/merge.hpp | 11 +- sprout/algorithm/fit/partition.hpp | 4 +- sprout/algorithm/fit/partition_copy.hpp | 9 +- sprout/algorithm/fit/remove.hpp | 8 +- sprout/algorithm/fit/remove_copy.hpp | 7 +- sprout/algorithm/fit/remove_copy_if.hpp | 7 +- sprout/algorithm/fit/remove_if.hpp | 4 +- sprout/algorithm/fit/replace_copy.hpp | 3 +- sprout/algorithm/fit/replace_copy_if.hpp | 3 +- sprout/algorithm/fit/reverse_copy.hpp | 3 +- sprout/algorithm/fit/rotate_copy.hpp | 3 +- sprout/algorithm/fit/set_difference.hpp | 15 +- sprout/algorithm/fit/set_intersection.hpp | 11 +- .../fit/set_symmetric_difference.hpp | 16 +- sprout/algorithm/fit/set_union.hpp | 15 +- sprout/algorithm/fit/stable_partition.hpp | 4 +- .../algorithm/fit/stable_partition_copy.hpp | 4 +- sprout/algorithm/fit/swap_element_copy.hpp | 3 +- sprout/algorithm/fit/transform.hpp | 5 +- sprout/algorithm/fit/unique_copy.hpp | 11 +- sprout/array/array.hpp | 6 +- sprout/complex/complex.hpp | 4 +- sprout/compost/effects/distorted.hpp | 2 +- sprout/compost/effects/fuzzed.hpp | 2 +- sprout/compost/effects/overdriven.hpp | 2 +- sprout/container.hpp | 1 + .../container/container_construct_traits.hpp | 2 +- sprout/container/container_fitness_traits.hpp | 29 ++ sprout/container/container_holder.hpp | 152 +++++++++ sprout/container/deep_internal.hpp | 37 ++ sprout/container/fit_size.hpp | 22 ++ sprout/container/functions.hpp | 2 + sprout/container/get_deep_internal.hpp | 43 +++ sprout/container/internal_begin.hpp | 16 +- sprout/container/internal_deep_copy.hpp | 8 +- sprout/container/internal_end.hpp | 16 +- sprout/container/is_sub_container.hpp | 23 ++ sprout/container/metafunctions.hpp | 2 + sprout/container/sub_container_traits.hpp | 3 +- sprout/container/traits.hpp | 1 + sprout/container/utility.hpp | 7 + sprout/iterator/adaptor.hpp | 1 + sprout/iterator/back_insert_iterator.hpp | 166 +++++++++ sprout/iterator/dft_iterator.hpp | 1 - sprout/iterator/front_insert_iterator.hpp | 166 +++++++++ sprout/iterator/idft_iterator.hpp | 1 - sprout/iterator/insert_range_iterator.hpp | 322 ++++++++++++++++++ sprout/iterator/inserter.hpp | 8 + sprout/iterator/joint_iterator.hpp | 5 +- sprout/iterator/predefined.hpp | 1 + sprout/iterator/remake_iterator.hpp | 8 +- sprout/iterator/step_iterator.hpp | 1 - sprout/math/bernoulli.hpp | 2 +- sprout/numeric/dft/fit/amplitude_spectrum.hpp | 3 +- sprout/numeric/dft/fit/dft.hpp | 3 +- sprout/numeric/dft/fit/idft.hpp | 3 +- sprout/numeric/dft/fit/phase_spectrum.hpp | 3 +- sprout/numeric/fit/adjacent_difference.hpp | 3 +- sprout/numeric/fit/partial_sum.hpp | 3 +- sprout/random/uniform_smallint.hpp | 2 +- sprout/rational/rational.hpp | 8 +- sprout/sub_array/sub_array.hpp | 8 +- 70 files changed, 1094 insertions(+), 186 deletions(-) create mode 100644 sprout/container/container_fitness_traits.hpp create mode 100644 sprout/container/container_holder.hpp create mode 100644 sprout/container/deep_internal.hpp create mode 100644 sprout/container/fit_size.hpp create mode 100644 sprout/container/get_deep_internal.hpp create mode 100644 sprout/container/is_sub_container.hpp create mode 100644 sprout/container/utility.hpp create mode 100644 sprout/iterator/back_insert_iterator.hpp create mode 100644 sprout/iterator/front_insert_iterator.hpp create mode 100644 sprout/iterator/insert_range_iterator.hpp create mode 100644 sprout/iterator/inserter.hpp diff --git a/sprout/algorithm/fit.hpp b/sprout/algorithm/fit.hpp index 6eb69c2c..cf11d9f6 100644 --- a/sprout/algorithm/fit.hpp +++ b/sprout/algorithm/fit.hpp @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/sprout/algorithm/fit/clamp_range_copy.hpp b/sprout/algorithm/fit/clamp_range_copy.hpp index e37db67b..105c75cf 100644 --- a/sprout/algorithm/fit/clamp_range_copy.hpp +++ b/sprout/algorithm/fit/clamp_range_copy.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -28,7 +27,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::clamp_range_copy(first, last, result, low, high, comp)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail @@ -61,7 +60,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::clamp_range_copy(first, last, result, low, high)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/copy.hpp b/sprout/algorithm/fit/copy.hpp index 12d11d47..6f2558e1 100644 --- a/sprout/algorithm/fit/copy.hpp +++ b/sprout/algorithm/fit/copy.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -25,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::copy(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/copy_backward.hpp b/sprout/algorithm/fit/copy_backward.hpp index 5eaeb9e2..dec28e34 100644 --- a/sprout/algorithm/fit/copy_backward.hpp +++ b/sprout/algorithm/fit/copy_backward.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -23,7 +22,7 @@ namespace sprout { { return sprout::sub_copy( sprout::get_internal(sprout::fixed::copy_backward(first, last, result)), - offset - NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)), + offset - sprout::fit_size(result, sprout::distance(first, last)), offset ); } diff --git a/sprout/algorithm/fit/copy_if.hpp b/sprout/algorithm/fit/copy_if.hpp index e60d61dc..db3eaf31 100644 --- a/sprout/algorithm/fit/copy_if.hpp +++ b/sprout/algorithm/fit/copy_if.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -24,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::copy_if(first, last, result, pred)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::count_if(first, last, pred), sprout::size(result)) + offset + sprout::fit_size(result, sprout::count_if(first, last, pred)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/copy_n.hpp b/sprout/algorithm/fit/copy_n.hpp index ecc62db9..002f173f 100644 --- a/sprout/algorithm/fit/copy_n.hpp +++ b/sprout/algorithm/fit/copy_n.hpp @@ -8,7 +8,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -23,7 +22,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::copy_n(first, n, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(n, sprout::size(result)) + offset + sprout::fit_size(result, n) ); } } // namespace detail diff --git a/sprout/algorithm/fit/copy_until.hpp b/sprout/algorithm/fit/copy_until.hpp index 9f54a7e9..6706478c 100644 --- a/sprout/algorithm/fit/copy_until.hpp +++ b/sprout/algorithm/fit/copy_until.hpp @@ -5,12 +5,11 @@ #include #include #include +#include #include #include -#include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -26,10 +25,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::copy_until(first, last, result, pred)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, sprout::find_if(first, last, pred)), - sprout::size(result) - ) + offset + sprout::fit_size(result, sprout::distance(first, sprout::find_if(first, last, pred))) ); } } // namespace detail diff --git a/sprout/algorithm/fit/copy_while.hpp b/sprout/algorithm/fit/copy_while.hpp index f3feb3f8..6d84ff84 100644 --- a/sprout/algorithm/fit/copy_while.hpp +++ b/sprout/algorithm/fit/copy_while.hpp @@ -5,12 +5,11 @@ #include #include #include +#include #include #include -#include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -26,10 +25,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::copy_while(first, last, result, pred)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, sprout::find_if_not(first, last, pred)), - sprout::size(result) - ) + offset + sprout::fit_size(result, sprout::distance(first, sprout::find_if_not(first, last, pred))) ); } } // namespace detail diff --git a/sprout/algorithm/fit/merge.hpp b/sprout/algorithm/fit/merge.hpp index 4d89b7a2..b0f1082c 100644 --- a/sprout/algorithm/fit/merge.hpp +++ b/sprout/algorithm/fit/merge.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -27,10 +26,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::merge(first1, last1, first2, last2, result, comp)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first1, last1) + sprout::distance(first2, last2), - sprout::size(result) - ) + offset + sprout::fit_size(result, sprout::distance(first1, last1) + sprout::distance(first2, last2)) ); } } // namespace detail @@ -65,10 +61,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::merge(first1, last1, first2, last2, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first1, last1) + sprout::distance(first2, last2), - sprout::size(result) - ) + offset + sprout::fit_size(result, sprout::distance(first1, last1) + sprout::distance(first2, last2)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/partition.hpp b/sprout/algorithm/fit/partition.hpp index 6d5b11d7..41cfb63a 100644 --- a/sprout/algorithm/fit/partition.hpp +++ b/sprout/algorithm/fit/partition.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -23,7 +23,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::partition(cont, pred)), offset, - offset + sprout::size(cont) - NS_SSCRISK_CEL_OR_SPROUT::count_if(sprout::begin(cont), sprout::end(cont), pred) + offset + sprout::size(cont) - sprout::count_if(sprout::begin(cont), sprout::end(cont), pred) ); } } // namespace detail diff --git a/sprout/algorithm/fit/partition_copy.hpp b/sprout/algorithm/fit/partition_copy.hpp index 0ca303cb..45229171 100644 --- a/sprout/algorithm/fit/partition_copy.hpp +++ b/sprout/algorithm/fit/partition_copy.hpp @@ -11,7 +11,6 @@ #include #include #include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT -#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -27,12 +26,8 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::partition_copy(first, last, result, pred)), offset, - offset + sprout::detail::count_n_if( - first, - NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, last), sprout::size(result) - ), - pred + offset + sprout::fit_size( + result, sprout::detail::count_n_if(first, NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)), pred) ) ); } diff --git a/sprout/algorithm/fit/remove.hpp b/sprout/algorithm/fit/remove.hpp index 4e5895ad..2aa4b367 100644 --- a/sprout/algorithm/fit/remove.hpp +++ b/sprout/algorithm/fit/remove.hpp @@ -4,11 +4,11 @@ #include #include #include -#include -#include +#include +#include +#include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -23,7 +23,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::remove(cont, value)), offset, - offset + sprout::size(cont) - NS_SSCRISK_CEL_OR_SPROUT::count(sprout::begin(cont), sprout::end(cont), value) + offset + sprout::size(cont) - sprout::count(sprout::begin(cont), sprout::end(cont), value) ); } } // namespace detail diff --git a/sprout/algorithm/fit/remove_copy.hpp b/sprout/algorithm/fit/remove_copy.hpp index 579dd428..6cbc9d13 100644 --- a/sprout/algorithm/fit/remove_copy.hpp +++ b/sprout/algorithm/fit/remove_copy.hpp @@ -5,11 +5,11 @@ #include #include #include +#include #include #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -25,10 +25,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::remove_copy(first, last, result, value)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, last) - NS_SSCRISK_CEL_OR_SPROUT::count(first, last, value), - sprout::size(result) - ) + offset + sprout::fit_size(result, sprout::distance(first, last) - sprout::count(first, last, value)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/remove_copy_if.hpp b/sprout/algorithm/fit/remove_copy_if.hpp index fbf1096e..0aa024a1 100644 --- a/sprout/algorithm/fit/remove_copy_if.hpp +++ b/sprout/algorithm/fit/remove_copy_if.hpp @@ -5,11 +5,11 @@ #include #include #include +#include #include #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -25,10 +25,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::remove_copy_if(first, last, result, pred)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, last) - NS_SSCRISK_CEL_OR_SPROUT::count_if(first, last, pred), - sprout::size(result) - ) + offset + sprout::fit_size(result, sprout::distance(first, last) - sprout::count_if(first, last, pred)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/remove_if.hpp b/sprout/algorithm/fit/remove_if.hpp index 333b8fbb..d1f6ca79 100644 --- a/sprout/algorithm/fit/remove_if.hpp +++ b/sprout/algorithm/fit/remove_if.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -23,7 +23,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::remove_if(cont, pred)), offset, - offset + sprout::size(cont) - NS_SSCRISK_CEL_OR_SPROUT::count_if(sprout::begin(cont), sprout::end(cont), pred) + offset + sprout::size(cont) - sprout::count_if(sprout::begin(cont), sprout::end(cont), pred) ); } } // namespace detail diff --git a/sprout/algorithm/fit/replace_copy.hpp b/sprout/algorithm/fit/replace_copy.hpp index ca2e3cbe..535f1c17 100644 --- a/sprout/algorithm/fit/replace_copy.hpp +++ b/sprout/algorithm/fit/replace_copy.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -25,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::replace_copy(first, last, result, old_value, new_value)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/replace_copy_if.hpp b/sprout/algorithm/fit/replace_copy_if.hpp index 88e333d2..55d6eade 100644 --- a/sprout/algorithm/fit/replace_copy_if.hpp +++ b/sprout/algorithm/fit/replace_copy_if.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -25,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::replace_copy_if(first, last, result, pred, new_value)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/reverse_copy.hpp b/sprout/algorithm/fit/reverse_copy.hpp index 337afe93..2201bfda 100644 --- a/sprout/algorithm/fit/reverse_copy.hpp +++ b/sprout/algorithm/fit/reverse_copy.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -24,7 +23,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::reverse_copy(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/rotate_copy.hpp b/sprout/algorithm/fit/rotate_copy.hpp index 2614b7c8..79f720f0 100644 --- a/sprout/algorithm/fit/rotate_copy.hpp +++ b/sprout/algorithm/fit/rotate_copy.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -24,7 +23,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::rotate_copy(first, middle, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/set_difference.hpp b/sprout/algorithm/fit/set_difference.hpp index f73a8b8f..4c16507d 100644 --- a/sprout/algorithm/fit/set_difference.hpp +++ b/sprout/algorithm/fit/set_difference.hpp @@ -10,7 +10,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -28,11 +27,8 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::set_difference(first1, last1, first2, last2, result, comp)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first1, last1) - - sprout::detail::set_overlap_count(first1, last1, first2, last2, comp) - , - sprout::size(result) + offset + sprout::fit_size( + result, sprout::distance(first1, last1) - sprout::detail::set_overlap_count(first1, last1, first2, last2, comp) ) ); } @@ -68,11 +64,8 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::set_difference(first1, last1, first2, last2, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first1, last1) - - sprout::detail::set_overlap_count(first1, last1, first2, last2) - , - sprout::size(result) + offset + sprout::fit_size( + result, sprout::distance(first1, last1) - sprout::detail::set_overlap_count(first1, last1, first2, last2) ) ); } diff --git a/sprout/algorithm/fit/set_intersection.hpp b/sprout/algorithm/fit/set_intersection.hpp index 90b7bfdd..9643b6d6 100644 --- a/sprout/algorithm/fit/set_intersection.hpp +++ b/sprout/algorithm/fit/set_intersection.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -27,9 +26,8 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::set_intersection(first1, last1, first2, last2, result, comp)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::detail::set_overlap_count(first1, last1, first2, last2, comp), - sprout::size(result) + offset + sprout::fit_size( + result, sprout::detail::set_overlap_count(first1, last1, first2, last2, comp) ) ); } @@ -65,9 +63,8 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::set_intersection(first1, last1, first2, last2, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::detail::set_overlap_count(first1, last1, first2, last2), - sprout::size(result) + offset + sprout::fit_size( + result, sprout::detail::set_overlap_count(first1, last1, first2, last2) ) ); } diff --git a/sprout/algorithm/fit/set_symmetric_difference.hpp b/sprout/algorithm/fit/set_symmetric_difference.hpp index 6088a471..40194506 100644 --- a/sprout/algorithm/fit/set_symmetric_difference.hpp +++ b/sprout/algorithm/fit/set_symmetric_difference.hpp @@ -10,7 +10,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -28,11 +27,8 @@ namespace sprout { return sprout::sub_copy( 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) - - 2 * sprout::detail::set_overlap_count(first1, last1, first2, last2, comp) - , - sprout::size(result) + offset + sprout::fit_size( + result, sprout::distance(first1, last1) + sprout::distance(first2, last2) - 2 * sprout::detail::set_overlap_count(first1, last1, first2, last2, comp) ) ); } @@ -68,12 +64,8 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::set_symmetric_difference(first1, last1, first2, last2, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first1, last1) - + sprout::distance(first2, last2) - - 2 * sprout::detail::set_overlap_count(first1, last1, first2, last2) - , - sprout::size(result) + offset + sprout::fit_size( + result, sprout::distance(first1, last1) + sprout::distance(first2, last2) - 2 * sprout::detail::set_overlap_count(first1, last1, first2, last2) ) ); } diff --git a/sprout/algorithm/fit/set_union.hpp b/sprout/algorithm/fit/set_union.hpp index 19187ea9..24f63560 100644 --- a/sprout/algorithm/fit/set_union.hpp +++ b/sprout/algorithm/fit/set_union.hpp @@ -10,7 +10,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -28,11 +27,8 @@ namespace sprout { return sprout::sub_copy( 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::detail::set_overlap_count(first1, last1, first2, last2, comp) - , - sprout::size(result) + offset + sprout::fit_size( + result, sprout::distance(first1, last1) + sprout::distance(first2, last2) - sprout::detail::set_overlap_count(first1, last1, first2, last2, comp) ) ); } @@ -68,11 +64,8 @@ namespace sprout { return sprout::sub_copy( 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::detail::set_overlap_count(first1, last1, first2, last2) - , - sprout::size(result) + offset + sprout::fit_size( + result, sprout::distance(first1, last1) + sprout::distance(first2, last2) - sprout::detail::set_overlap_count(first1, last1, first2, last2) ) ); } diff --git a/sprout/algorithm/fit/stable_partition.hpp b/sprout/algorithm/fit/stable_partition.hpp index cae4b917..188ee1ce 100644 --- a/sprout/algorithm/fit/stable_partition.hpp +++ b/sprout/algorithm/fit/stable_partition.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -23,7 +23,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::stable_partition(cont, pred)), offset, - offset + sprout::size(cont) - NS_SSCRISK_CEL_OR_SPROUT::count_if(sprout::begin(cont), sprout::end(cont), pred) + offset + sprout::size(cont) - sprout::count_if(sprout::begin(cont), sprout::end(cont), pred) ); } } // namespace detail diff --git a/sprout/algorithm/fit/stable_partition_copy.hpp b/sprout/algorithm/fit/stable_partition_copy.hpp index 9a8b4977..79c90f65 100644 --- a/sprout/algorithm/fit/stable_partition_copy.hpp +++ b/sprout/algorithm/fit/stable_partition_copy.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -24,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::stable_partition_copy(first, last, result, pred)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::count_if(first, last, pred), sprout::size(result)) + offset + sprout::fit_size(result, sprout::count_if(first, last, pred)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/swap_element_copy.hpp b/sprout/algorithm/fit/swap_element_copy.hpp index af59e989..50da786b 100644 --- a/sprout/algorithm/fit/swap_element_copy.hpp +++ b/sprout/algorithm/fit/swap_element_copy.hpp @@ -8,7 +8,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -24,7 +23,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::swap_element_copy(first, last, result, pos1, pos2)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/transform.hpp b/sprout/algorithm/fit/transform.hpp index 674dd76e..d37263f0 100644 --- a/sprout/algorithm/fit/transform.hpp +++ b/sprout/algorithm/fit/transform.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -25,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::transform(first, last, result, op)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail @@ -50,7 +49,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::transform(first1, last1, first2, result, op)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first1, last1), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first1, last1)) ); } } // namespace detail diff --git a/sprout/algorithm/fit/unique_copy.hpp b/sprout/algorithm/fit/unique_copy.hpp index 528aa34d..15962848 100644 --- a/sprout/algorithm/fit/unique_copy.hpp +++ b/sprout/algorithm/fit/unique_copy.hpp @@ -10,7 +10,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -26,10 +25,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::unique_copy(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, last) - sprout::detail::overlap_count(first, last), - sprout::size(result) - ) + offset + sprout::fit_size(result, sprout::distance(first, last) - sprout::detail::overlap_count(first, last)) ); } } // namespace detail @@ -54,10 +50,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::unique_copy(first, last, result, pred)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min( - sprout::distance(first, last) - sprout::detail::overlap_count(first, last, pred), - sprout::size(result) - ) + offset + sprout::fit_size(result, sprout::distance(first, last) - sprout::detail::overlap_count(first, last, pred)) ); } } // namespace detail diff --git a/sprout/array/array.hpp b/sprout/array/array.hpp index 6935d2e4..665872e1 100644 --- a/sprout/array/array.hpp +++ b/sprout/array/array.hpp @@ -60,7 +60,7 @@ namespace sprout { SPROUT_CONSTEXPR array fill(const_reference value) const { return fill_impl(value, sprout::index_n<0, N>::make()); } - void swap(array& other) + void swap(array& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval(), std::declval()))) { std::swap_ranges(other.begin(), other.end(), begin()); @@ -176,12 +176,12 @@ namespace sprout { } // others: template - array& operator=(array const& rhs) { + array& operator=(array const& rhs) { std::copy(rhs.begin(), rhs.end(), begin()); return *this; } template - array& operator=(array&& rhs) { + array& operator=(array&& rhs) { std::move(rhs.begin(), rhs.end(), begin()); return *this; } diff --git a/sprout/complex/complex.hpp b/sprout/complex/complex.hpp index 8b808aa4..db9e8671 100644 --- a/sprout/complex/complex.hpp +++ b/sprout/complex/complex.hpp @@ -27,12 +27,12 @@ namespace sprout { T im_; public: SPROUT_CONSTEXPR complex(T const& re = T(), T const& im = T()) SPROUT_NOEXCEPT - : re_(re) , im_(im) + : re_(re), im_(im) {} SPROUT_CONSTEXPR complex(complex const&) = default; template SPROUT_CONSTEXPR complex(complex const& other) SPROUT_NOEXCEPT - : re_(other.real()) , im_(other.imag()) + : re_(other.real()), im_(other.imag()) {} SPROUT_CONSTEXPR T real() const SPROUT_NOEXCEPT { return re_; diff --git a/sprout/compost/effects/distorted.hpp b/sprout/compost/effects/distorted.hpp index e8771c94..4554e484 100644 --- a/sprout/compost/effects/distorted.hpp +++ b/sprout/compost/effects/distorted.hpp @@ -23,7 +23,7 @@ namespace sprout { distort_holder() = default; distort_holder(distort_holder const&) = default; SPROUT_CONSTEXPR distort_holder(value_type const& gain, value_type const& level) - : gain_(gain) , level_(level) + : gain_(gain), level_(level) {} SPROUT_CONSTEXPR value_type const& gain() const { return gain_; diff --git a/sprout/compost/effects/fuzzed.hpp b/sprout/compost/effects/fuzzed.hpp index c2308271..6c70ce96 100644 --- a/sprout/compost/effects/fuzzed.hpp +++ b/sprout/compost/effects/fuzzed.hpp @@ -24,7 +24,7 @@ namespace sprout { fuzz_holder() = default; fuzz_holder(fuzz_holder const&) = default; SPROUT_CONSTEXPR fuzz_holder(value_type const& gain, value_type const& level) - : gain_(gain) , level_(level) + : gain_(gain), level_(level) {} SPROUT_CONSTEXPR value_type const& gain() const { return gain_; diff --git a/sprout/compost/effects/overdriven.hpp b/sprout/compost/effects/overdriven.hpp index b9e00659..38bf159e 100644 --- a/sprout/compost/effects/overdriven.hpp +++ b/sprout/compost/effects/overdriven.hpp @@ -51,7 +51,7 @@ namespace sprout { overdrive_holder() = default; overdrive_holder(overdrive_holder const&) = default; SPROUT_CONSTEXPR overdrive_holder(value_type const& gain, value_type const& level) - : gain_(gain) , level_(level) + : gain_(gain), level_(level) {} SPROUT_CONSTEXPR value_type const& gain() const { return gain_; diff --git a/sprout/container.hpp b/sprout/container.hpp index 8344514a..7bb830e1 100644 --- a/sprout/container.hpp +++ b/sprout/container.hpp @@ -5,5 +5,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_CONTAINER_HPP diff --git a/sprout/container/container_construct_traits.hpp b/sprout/container/container_construct_traits.hpp index 9e0517f8..ddc59f0b 100644 --- a/sprout/container/container_construct_traits.hpp +++ b/sprout/container/container_construct_traits.hpp @@ -50,7 +50,7 @@ namespace sprout { } template inline SPROUT_CONSTEXPR typename std::enable_if< - !sprout::is_fixed_container::value, + !sprout::is_fixed_container::value && sizeof...(Args) != 2, typename sprout::container_construct_traits::copied_type >::type default_remake_container(Cont&& cont, typename sprout::container_traits::difference_type size, Args&&... args) { diff --git a/sprout/container/container_fitness_traits.hpp b/sprout/container/container_fitness_traits.hpp new file mode 100644 index 00000000..6e711a38 --- /dev/null +++ b/sprout/container/container_fitness_traits.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_CONTAINER_CONTAINER_FITNESS_TRAITS_HPP +#define SPROUT_CONTAINER_CONTAINER_FITNESS_TRAITS_HPP + +#include +#include +#include +#include +#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT + +namespace sprout { + // + // container_fitness_traits + // + template + struct container_fitness_traits { + public: + template + static SPROUT_CONSTEXPR typename sprout::container_traits::difference_type + fit_size(Cont&& cont, typename sprout::container_traits::difference_type size) { + return NS_SSCRISK_CEL_OR_SPROUT::min(size, sprout::size(sprout::forward(cont))); + } + }; + template + struct container_fitness_traits + : public sprout::container_fitness_traits + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_CONTAINER_CONTAINER_FITNESS_TRAITS_HPP diff --git a/sprout/container/container_holder.hpp b/sprout/container/container_holder.hpp new file mode 100644 index 00000000..146f85dd --- /dev/null +++ b/sprout/container/container_holder.hpp @@ -0,0 +1,152 @@ +#ifndef SPROUT_CONTAINER_CONTAINER_HOLDER_HPP +#define SPROUT_CONTAINER_CONTAINER_HOLDER_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // container_holder + // + template + class container_holder + : public sprout::container_traits_facade + { + private: + typedef sprout::container_traits_facade facade_type; + public: + typedef Container container_type; + typedef container_type internal_type; + typedef typename facade_type::iterator iterator; + typedef typename facade_type::const_iterator const_iterator; + typedef typename facade_type::reference reference; + typedef typename facade_type::const_reference const_reference; + typedef typename facade_type::size_type size_type; + typedef typename facade_type::difference_type difference_type; + typedef typename facade_type::pointer pointer; + typedef typename facade_type::const_pointer const_pointer; + typedef internal_type& param_type; + typedef internal_type const& const_param_type; + typedef sprout::value_holder holder_type; + protected: + holder_type container; + public: + SPROUT_CONSTEXPR container_holder() + : container() + {} + explicit SPROUT_CONSTEXPR container_holder(param_type x) + : container(x) + {} + SPROUT_CONSTEXPR container_holder(container_holder const&) = default; + + void swap(container_holder& other) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(other.container, container))) + { + sprout::swap(other.container, container); + } + // iterators: + iterator begin() { + return sprout::begin(*container); + } + SPROUT_CONSTEXPR const_iterator begin() const { + return sprout::begin(*container); + } + iterator end() { + return sprout::end(*container); + } + SPROUT_CONSTEXPR const_iterator end() const { + return sprout::end(*container); + } + SPROUT_CONSTEXPR const_iterator cbegin() const { + return sprout::begin(*container); + } + SPROUT_CONSTEXPR const_iterator cend() const { + return sprout::end(*container); + } + // capacity: + SPROUT_CONSTEXPR size_type size() const SPROUT_NOEXCEPT { + return sprout::size(*container); + } + SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT { + return sprout::empty(*container); + } + + param_type get_internal() { + return *container; + } + SPROUT_CONSTEXPR const_param_type get_internal() const { + return *container; + } + }; + + // + // swap + // + template + inline void + swap(sprout::container_holder& lhs, sprout::container_holder& rhs) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) + { + lhs.swap(rhs); + } + + // + // container_construct_traits + // + template + struct container_construct_traits > { + public: + typedef typename sprout::container_construct_traits::copied_type copied_type; + public: + template + static SPROUT_CONSTEXPR copied_type + deep_copy(Cont&& cont) { + return sprout::deep_copy(sprout::get_internal(sprout::forward(cont))); + } + template + static SPROUT_CONSTEXPR copied_type + make(Args&&... args) { + return sprout::make(sprout::forward(args)...); + } + template + static SPROUT_CONSTEXPR copied_type + remake(Cont&& cont, typename sprout::container_traits::difference_type size, Args&&... args) { + return sprout::remake(sprout::get_internal(sprout::forward(cont)), size, sprout::forward(args)...); + } + }; + + // + // sub_container_traits + // + template + struct sub_container_traits > { + private: + static typename sprout::container_holder::param_type + call(sprout::container_holder& cont) { + return cont.get_internal(); + } + static SPROUT_CONSTEXPR typename sprout::container_holder::const_param_type + call(sprout::container_holder const& cont) { + return cont.get_internal(); + } + public: + template + struct internal { + public: + typedef decltype(call(std::declval())) type; + }; + public: + template + static SPROUT_CONSTEXPR typename internal::type + get_internal(Cont&& cont) { + return call(sprout::forward(cont)); + } + }; +} // namespace sprout + +#endif // #ifndef SPROUT_CONTAINER_CONTAINER_HOLDER_HPP diff --git a/sprout/container/deep_internal.hpp b/sprout/container/deep_internal.hpp new file mode 100644 index 00000000..5e693ca1 --- /dev/null +++ b/sprout/container/deep_internal.hpp @@ -0,0 +1,37 @@ +#ifndef SPROUT_CONTAINER_DEEP_INTERNAL_HPP +#define SPROUT_CONTAINER_DEEP_INTERNAL_HPP + +#include +#include +#include + +namespace sprout { + namespace containers { + namespace detail { + template + struct deep_internal_impl + : public sprout::containers::detail::deep_internal_impl< + typename sprout::containers::internal::type, Container + > + {}; + template + struct deep_internal_impl< + Container, Prev, + typename std::enable_if::value>::type + > + : public std::common_type + {}; + } // namespace detail + // + // deep_internal + // + template + struct deep_internal + : public sprout::containers::detail::deep_internal_impl< + typename sprout::containers::internal::type, Container + > + {}; + } // namespace containers +} // namespace sprout + +#endif // #ifndef SPROUT_CONTAINER_DEEP_INTERNAL_HPP diff --git a/sprout/container/fit_size.hpp b/sprout/container/fit_size.hpp new file mode 100644 index 00000000..6242c475 --- /dev/null +++ b/sprout/container/fit_size.hpp @@ -0,0 +1,22 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIT_SIZE_HPP +#define SPROUT_FIXED_CONTAINER_FIT_SIZE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + // + // fit_size + // + template + inline SPROUT_CONSTEXPR typename sprout::container_traits::type>::difference_type + fit_size(Container&& cont, typename sprout::container_traits::type>::difference_type size) { + typedef typename std::remove_reference::type container_type; + return sprout::container_fitness_traits::fit_size(sprout::forward(cont), size); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_FIT_SIZE_HPP diff --git a/sprout/container/functions.hpp b/sprout/container/functions.hpp index 9b7ea053..55f79b5c 100644 --- a/sprout/container/functions.hpp +++ b/sprout/container/functions.hpp @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/sprout/container/get_deep_internal.hpp b/sprout/container/get_deep_internal.hpp new file mode 100644 index 00000000..5894edad --- /dev/null +++ b/sprout/container/get_deep_internal.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_FIXED_CONTAINER_GET_DEEP_INTERNAL_HPP +#define SPROUT_FIXED_CONTAINER_GET_DEEP_INTERNAL_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template< + typename Container, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::containers::deep_internal::type + get_deep_internal_impl(Container&& cont) { + return sprout::forward(cont); + } + template< + typename Container, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::containers::deep_internal::type + get_deep_internal_impl(Container&& cont) { + return sprout::detail::get_deep_internal_impl( + sprout::get_internal(sprout::forward(cont)) + ); + } + } // namespace detail + // + // get_deep_internal + // + template + inline SPROUT_CONSTEXPR typename sprout::containers::deep_internal::type + get_deep_internal(Container&& cont) { + return sprout::detail::get_deep_internal_impl(sprout::forward(cont)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_GET_DEEP_INTERNAL_HPP diff --git a/sprout/container/internal_begin.hpp b/sprout/container/internal_begin.hpp index 0d529c85..4eae1b3d 100644 --- a/sprout/container/internal_begin.hpp +++ b/sprout/container/internal_begin.hpp @@ -5,9 +5,9 @@ #include #include #include -#include +#include #include -#include +#include namespace sprout { // @@ -16,20 +16,20 @@ namespace sprout { template typename sprout::container_traits< typename std::remove_reference< - typename sprout::containers::internal::type + typename sprout::containers::deep_internal::type >::type >::iterator internal_begin(Container& cont) { - return sprout::begin(sprout::get_internal(cont)); + return sprout::begin(sprout::get_deep_internal(cont)); } template inline SPROUT_CONSTEXPR typename sprout::container_traits< typename std::remove_reference< - typename sprout::containers::internal::type + typename sprout::containers::deep_internal::type >::type >::const_iterator internal_begin(Container const& cont) { - return sprout::begin(sprout::get_internal(cont)); + return sprout::begin(sprout::get_deep_internal(cont)); } // @@ -38,11 +38,11 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::container_traits< typename std::remove_reference< - typename sprout::containers::internal::type + typename sprout::containers::deep_internal::type >::type >::const_iterator internal_cbegin(Container const& cont) { - return sprout::begin(sprout::get_internal(cont)); + return sprout::begin(sprout::get_deep_internal(cont)); } } // namespace sprout diff --git a/sprout/container/internal_deep_copy.hpp b/sprout/container/internal_deep_copy.hpp index 511633b3..8b91ee72 100644 --- a/sprout/container/internal_deep_copy.hpp +++ b/sprout/container/internal_deep_copy.hpp @@ -5,9 +5,9 @@ #include #include #include -#include +#include #include -#include +#include #include namespace sprout { @@ -17,12 +17,12 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::container_construct_traits< typename std::remove_reference< - typename sprout::containers::internal::type + typename sprout::containers::deep_internal::type >::type >::copied_type internal_deep_copy(Container&& cont) { return sprout::deep_copy( - sprout::get_internal(sprout::forward(cont)) + sprout::get_deep_internal(sprout::forward(cont)) ); } } // namespace sprout diff --git a/sprout/container/internal_end.hpp b/sprout/container/internal_end.hpp index 7050e4f5..a6fff6a7 100644 --- a/sprout/container/internal_end.hpp +++ b/sprout/container/internal_end.hpp @@ -5,9 +5,9 @@ #include #include #include -#include +#include #include -#include +#include namespace sprout { // @@ -16,20 +16,20 @@ namespace sprout { template typename sprout::container_traits< typename std::remove_reference< - typename sprout::containers::internal::type + typename sprout::containers::deep_internal::type >::type >::iterator internal_end(Container& cont) { - return sprout::end(sprout::get_internal(cont)); + return sprout::end(sprout::get_deep_internal(cont)); } template inline SPROUT_CONSTEXPR typename sprout::container_traits< typename std::remove_reference< - typename sprout::containers::internal::type + typename sprout::containers::deep_internal::type >::type >::const_iterator internal_end(Container const& cont) { - return sprout::end(sprout::get_internal(cont)); + return sprout::end(sprout::get_deep_internal(cont)); } // @@ -38,11 +38,11 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename sprout::container_traits< typename std::remove_reference< - typename sprout::containers::internal::type + typename sprout::containers::deep_internal::type >::type >::const_iterator internal_cend(Container const& cont) { - return sprout::end(sprout::get_internal(cont)); + return sprout::end(sprout::get_deep_internal(cont)); } } // namespace sprout diff --git a/sprout/container/is_sub_container.hpp b/sprout/container/is_sub_container.hpp new file mode 100644 index 00000000..c8bca404 --- /dev/null +++ b/sprout/container/is_sub_container.hpp @@ -0,0 +1,23 @@ +#ifndef SPROUT_CONTAINER_IS_SUB_CONTAINER_HPP +#define SPROUT_CONTAINER_IS_SUB_CONTAINER_HPP + +#include +#include +#include + +namespace sprout { + namespace containers { + // + // is_sub_container + // + template + struct is_sub_container + : public std::integral_constant< + bool, + !std::is_same::type, Container&&>::value + > + {}; + } // namespace containers +} // namespace sprout + +#endif // #ifndef SPROUT_CONTAINER_IS_SUB_CONTAINER_HPP diff --git a/sprout/container/metafunctions.hpp b/sprout/container/metafunctions.hpp index 71d2bedb..9e4db857 100644 --- a/sprout/container/metafunctions.hpp +++ b/sprout/container/metafunctions.hpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #endif // #ifndef SPROUT_CONTAINER_METAFUNCTIONS_HPP diff --git a/sprout/container/sub_container_traits.hpp b/sprout/container/sub_container_traits.hpp index 571292d5..74a56daa 100644 --- a/sprout/container/sub_container_traits.hpp +++ b/sprout/container/sub_container_traits.hpp @@ -18,7 +18,8 @@ namespace sprout { }; public: template - static SPROUT_CONSTEXPR typename internal::type get_internal(Cont&& cont) { + static SPROUT_CONSTEXPR typename internal::type + get_internal(Cont&& cont) { return sprout::forward(cont); } }; diff --git a/sprout/container/traits.hpp b/sprout/container/traits.hpp index 4957fa67..6591c361 100644 --- a/sprout/container/traits.hpp +++ b/sprout/container/traits.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #endif // #ifndef SPROUT_CONTAINER_TRAITS_HPP diff --git a/sprout/container/utility.hpp b/sprout/container/utility.hpp new file mode 100644 index 00000000..efbbcfff --- /dev/null +++ b/sprout/container/utility.hpp @@ -0,0 +1,7 @@ +#ifndef SPROUT_CONTAINER_UTILITY_HPP +#define SPROUT_CONTAINER_UTILITY_HPP + +#include +#include + +#endif // #ifndef SPROUT_CONTAINER_UTILITY_HPP diff --git a/sprout/iterator/adaptor.hpp b/sprout/iterator/adaptor.hpp index d1dde63d..ecf9de13 100644 --- a/sprout/iterator/adaptor.hpp +++ b/sprout/iterator/adaptor.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/sprout/iterator/back_insert_iterator.hpp b/sprout/iterator/back_insert_iterator.hpp new file mode 100644 index 00000000..c1bc3263 --- /dev/null +++ b/sprout/iterator/back_insert_iterator.hpp @@ -0,0 +1,166 @@ +#ifndef SPROUT_ITERATOR_BACK_INSERT_ITERATOR_HPP +#define SPROUT_ITERATOR_BACK_INSERT_ITERATOR_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // back_insert_iterator + // + template + class back_insert_iterator + : public std::iterator + , public sprout::container_holder + { + private: + typedef sprout::container_holder base_type; + public: + typedef typename base_type::container_type container_type; + typedef typename base_type::internal_type internal_type; + typedef typename base_type::iterator iterator; + typedef typename base_type::const_iterator const_iterator; + typedef typename base_type::reference reference; + typedef typename base_type::const_reference const_reference; + typedef typename base_type::size_type size_type; + typedef typename base_type::difference_type difference_type; + typedef typename base_type::pointer pointer; + typedef typename base_type::const_pointer const_pointer; + typedef typename base_type::param_type param_type; + typedef typename base_type::const_param_type const_param_type; + typedef typename base_type::holder_type holder_type; + protected: + using base_type::container; + public: + SPROUT_CONSTEXPR back_insert_iterator() = default; + explicit SPROUT_CONSTEXPR back_insert_iterator(param_type x) + : base_type(x) + {} + SPROUT_CONSTEXPR back_insert_iterator(back_insert_iterator const&) = default; + back_insert_iterator& operator=(typename container_type::value_type const& value) { + container->push_back(value); + return *this; + } + back_insert_iterator& operator=(typename container_type::value_type&& value) { + container->push_back(sprout::move(value)); + return *this; + } + SPROUT_CONSTEXPR back_insert_iterator const& operator*() const { + return *this; + } + back_insert_iterator& operator*() { + return *this; + } + back_insert_iterator& operator++() { + return *this; + } + back_insert_iterator operator++(int) { + return *this; + } + + void swap(back_insert_iterator& other) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(base_type::swap(other))) + { + base_type::swap(other); + } + }; + + // + // swap + // + template + inline void + swap(sprout::back_insert_iterator& lhs, sprout::back_insert_iterator& rhs) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) + { + lhs.swap(rhs); + } + + // + // back_inserter + // + template + inline SPROUT_CONSTEXPR sprout::back_insert_iterator + back_inserter(Container& x) { + return sprout::back_insert_iterator(x); + } + template + inline SPROUT_CONSTEXPR sprout::back_insert_iterator + back_inserter(Container const& x) { + return sprout::back_insert_iterator(x); + } + + // + // container_construct_traits + // + template + struct container_construct_traits > { + public: + typedef typename sprout::container_construct_traits::copied_type copied_type; + private: + template + static SPROUT_CONSTEXPR copied_type + remake_impl(Cont&& cont, typename sprout::container_traits::difference_type size, InputIterator first, InputIterator last) { + return sprout::make( + sprout::make_insert_range_iterator( + sprout::internal_begin(cont), sprout::end(cont), + first, first, last + ), + sprout::make_insert_range_iterator( + sprout::internal_end(cont), sprout::end(cont), + last, first, last + ) + ); + } + public: + template + static SPROUT_CONSTEXPR copied_type + deep_copy(Cont&& cont) { + return sprout::deep_copy(sprout::get_internal(sprout::forward(cont))); + } + template + static SPROUT_CONSTEXPR copied_type + make(Args&&... args) { + return sprout::make(sprout::forward(args)...); + } + template + static SPROUT_CONSTEXPR copied_type + remake(Cont&& cont, typename sprout::container_traits::difference_type size, Args&&... args) { + return remake_impl(sprout::get_internal(sprout::forward(cont)), size, sprout::forward(args)...); + } + }; + + // + // container_fitness_traits + // + template + struct container_fitness_traits > { + public: + template + static SPROUT_CONSTEXPR typename sprout::container_traits::difference_type + fit_size(Cont&& cont, typename sprout::container_traits::difference_type size) { + return size + sprout::size(sprout::forward(cont)); + } + }; + + // + // sub_container_traits + // + template + struct sub_container_traits > + : public sprout::sub_container_traits > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_ITERATOR_BACK_INSERT_ITERATOR_HPP diff --git a/sprout/iterator/dft_iterator.hpp b/sprout/iterator/dft_iterator.hpp index c270b37f..2510f7f5 100644 --- a/sprout/iterator/dft_iterator.hpp +++ b/sprout/iterator/dft_iterator.hpp @@ -11,7 +11,6 @@ #include #include #include -#include namespace sprout { // diff --git a/sprout/iterator/front_insert_iterator.hpp b/sprout/iterator/front_insert_iterator.hpp new file mode 100644 index 00000000..5641bbcf --- /dev/null +++ b/sprout/iterator/front_insert_iterator.hpp @@ -0,0 +1,166 @@ +#ifndef SPROUT_ITERATOR_FRONT_INSERT_ITERATOR_HPP +#define SPROUT_ITERATOR_FRONT_INSERT_ITERATOR_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // front_insert_iterator + // + template + class front_insert_iterator + : public std::iterator + , public sprout::container_holder + { + private: + typedef sprout::container_holder base_type; + public: + typedef typename base_type::container_type container_type; + typedef typename base_type::internal_type internal_type; + typedef typename base_type::iterator iterator; + typedef typename base_type::const_iterator const_iterator; + typedef typename base_type::reference reference; + typedef typename base_type::const_reference const_reference; + typedef typename base_type::size_type size_type; + typedef typename base_type::difference_type difference_type; + typedef typename base_type::pointer pointer; + typedef typename base_type::const_pointer const_pointer; + typedef typename base_type::param_type param_type; + typedef typename base_type::const_param_type const_param_type; + typedef typename base_type::holder_type holder_type; + protected: + using base_type::container; + public: + SPROUT_CONSTEXPR front_insert_iterator() = default; + explicit SPROUT_CONSTEXPR front_insert_iterator(param_type x) + : base_type(x) + {} + SPROUT_CONSTEXPR front_insert_iterator(front_insert_iterator const&) = default; + front_insert_iterator& operator=(typename container_type::value_type const& value) { + container->push_front(value); + return *this; + } + front_insert_iterator& operator=(typename container_type::value_type&& value) { + container->push_front(sprout::move(value)); + return *this; + } + SPROUT_CONSTEXPR front_insert_iterator const& operator*() const { + return *this; + } + front_insert_iterator& operator*() { + return *this; + } + front_insert_iterator& operator++() { + return *this; + } + front_insert_iterator operator++(int) { + return *this; + } + + void swap(front_insert_iterator& other) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(base_type::swap(other))) + { + base_type::swap(other); + } + }; + + // + // swap + // + template + inline void + swap(sprout::front_insert_iterator& lhs, sprout::front_insert_iterator& rhs) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) + { + lhs.swap(rhs); + } + + // + // front_inserter + // + template + inline SPROUT_CONSTEXPR sprout::front_insert_iterator + front_inserter(Container& x) { + return sprout::front_insert_iterator(x); + } + template + inline SPROUT_CONSTEXPR sprout::front_insert_iterator + front_inserter(Container const& x) { + return sprout::front_insert_iterator(x); + } + + // + // container_construct_traits + // + template + struct container_construct_traits > { + public: + typedef typename sprout::container_construct_traits::copied_type copied_type; + private: + template + static SPROUT_CONSTEXPR copied_type + remake_impl(Cont&& cont, typename sprout::container_traits::difference_type size, InputIterator first, InputIterator last) { + return sprout::make( + sprout::make_insert_range_iterator( + sprout::internal_begin(cont), sprout::begin(cont), + first, first, last + ), + sprout::make_insert_range_iterator( + sprout::internal_end(cont), sprout::begin(cont), + last, first, last + ) + ); + } + public: + template + static SPROUT_CONSTEXPR copied_type + deep_copy(Cont&& cont) { + return sprout::deep_copy(sprout::get_internal(sprout::forward(cont))); + } + template + static SPROUT_CONSTEXPR copied_type + make(Args&&... args) { + return sprout::make(sprout::forward(args)...); + } + template + static SPROUT_CONSTEXPR copied_type + remake(Cont&& cont, typename sprout::container_traits::difference_type size, Args&&... args) { + return remake_impl(sprout::get_internal(sprout::forward(cont)), size, sprout::forward(args)...); + } + }; + + // + // container_fitness_traits + // + template + struct container_fitness_traits > { + public: + template + static SPROUT_CONSTEXPR typename sprout::container_traits::difference_type + fit_size(Cont&& cont, typename sprout::container_traits::difference_type size) { + return size + sprout::size(sprout::forward(cont)); + } + }; + + // + // sub_container_traits + // + template + struct sub_container_traits > + : public sprout::sub_container_traits > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_ITERATOR_FRONT_INSERT_ITERATOR_HPP diff --git a/sprout/iterator/idft_iterator.hpp b/sprout/iterator/idft_iterator.hpp index 2ce5d95f..7b3a9a3e 100644 --- a/sprout/iterator/idft_iterator.hpp +++ b/sprout/iterator/idft_iterator.hpp @@ -11,7 +11,6 @@ #include #include #include -#include namespace sprout { // diff --git a/sprout/iterator/insert_range_iterator.hpp b/sprout/iterator/insert_range_iterator.hpp new file mode 100644 index 00000000..937f2341 --- /dev/null +++ b/sprout/iterator/insert_range_iterator.hpp @@ -0,0 +1,322 @@ +#ifndef SPROUT_ITERATOR_INSERT_RANGE_ITERATOR_HPP +#define SPROUT_ITERATOR_INSERT_RANGE_ITERATOR_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // insert_range_iterator + // + template + class insert_range_iterator + : public std::iterator< + typename sprout::common_iterator_category::type, + typename sprout::common_iterator_value_type::type, + typename sprout::common_iterator_difference_type::type, + typename sprout::common_iterator_pointer::type, + typename sprout::common_iterator_reference::type + > + { + public: + typedef DstIterator iterator_type; + typedef SrcIterator iterator2_type; + typedef typename sprout::common_iterator_category::type iterator_category; + typedef typename sprout::common_iterator_value_type::type value_type; + typedef typename sprout::common_iterator_difference_type::type difference_type; + typedef typename sprout::common_iterator_pointer::type pointer; + typedef typename sprout::common_iterator_reference::type reference; + protected: + iterator_type current1; + iterator_type pos1; + iterator2_type current2; + iterator2_type first2; + iterator2_type last2; + private: + SPROUT_CONSTEXPR insert_range_iterator advance_impl(difference_type n) const { + return n >= 0 + ? current1 > pos1 ? insert_range_iterator(sprout::next(current1, n), pos1, current2, first2, last2) + : current1 == pos1 ? current2 == last2 ? insert_range_iterator(sprout::next(current1, n), pos1, current2, first2, last2) + : n <= sprout::distance(current2, last2) ? insert_range_iterator(current1, pos1, last2, sprout::next(current2, n), first2, last2) + : insert_range_iterator(sprout::next(current1, n - sprout::distance(current2, last2)), pos1, last2, first2, last2) + : n <= sprout::distance(current1, pos1) ? insert_range_iterator(sprout::next(current1, n), pos1, current2, first2, last2) + : n <= sprout::distance(current1, pos1) + sprout::distance(current2, last2) + ? insert_range_iterator(pos1, pos1, last2, sprout::next(current2, n - sprout::distance(current1, pos1)), first2, last2) + : insert_range_iterator(sprout::next(current1, n - sprout::distance(current1, pos1) - sprout::distance(current2, last2)), pos1, last2, first2, last2) + : current1 < pos1 ? insert_range_iterator(sprout::next(current1, n), pos1, current2, first2, last2) + : current1 == pos1 ? current2 == first2 ? insert_range_iterator(sprout::next(current1, n), pos1, current2, first2, last2) + : -n <= sprout::distance(first2, current2) ? insert_range_iterator(current1, pos1, last2, sprout::next(current2, n), first2, last2) + : insert_range_iterator(sprout::next(current1, n - sprout::distance(first2, current2)), pos1, first2, first2, last2) + : -n <= sprout::distance(pos1, current1) ? insert_range_iterator(sprout::next(current1, n), pos1, current2, first2, last2) + : -n <= sprout::distance(pos1, current1) + sprout::distance(first2, current2) + ? insert_range_iterator(pos1, pos1, last2, sprout::next(current2, n - sprout::distance(pos1, current1)), first2, last2) + : insert_range_iterator(sprout::next(current1, n - sprout::distance(pos1, current1) - sprout::distance(first2, current2)), pos1, first2, first2, last2) + ; + } + public: + insert_range_iterator() = default; + insert_range_iterator(insert_range_iterator const&) = default; + SPROUT_CONSTEXPR insert_range_iterator(iterator_type it1, iterator_type pos1, iterator2_type it2, iterator2_type first2, iterator2_type last2) + : current1(it1), pos1(pos1) + , current2(it2), first2(first2), last2(last2) + {} + template + SPROUT_CONSTEXPR insert_range_iterator(insert_range_iterator const& it) + : current1(it.base()), pos1(it.position()) + , current2(it.base2()), first2(it.first()), last2(it.last()) + {} + template + insert_range_iterator& operator=(insert_range_iterator const& it) { + insert_range_iterator temp(it); + temp.swap(*this); + return *this; + } + SPROUT_CONSTEXPR iterator_type base() const { + return current1; + } + SPROUT_CONSTEXPR iterator_type position() const { + return pos1; + } + SPROUT_CONSTEXPR iterator2_type base2() const { + return current2; + } + SPROUT_CONSTEXPR iterator2_type first() const { + return first2; + } + SPROUT_CONSTEXPR iterator2_type last() const { + return last2; + } + SPROUT_CONSTEXPR bool is_in_base() const { + return current1 != pos1 || current2 == last2; + } + SPROUT_CONSTEXPR reference operator*() const { + return is_in_base() ? *current1 : *current2; + } + SPROUT_CONSTEXPR pointer operator->() const { + return &*(*this); + } + insert_range_iterator& operator++() { + if (is_in_base()) { + ++current1; + } else { + ++current2; + } + return *this; + } + insert_range_iterator operator++(int) { + insert_range_iterator result(*this); + if (is_in_base()) { + ++current1; + } else { + ++current2; + } + return result; + } + insert_range_iterator& operator--() { + if (current1 != pos1 || current2 == first2) { + --current1; + } else { + --current2; + } + return *this; + } + insert_range_iterator operator--(int) { + insert_range_iterator temp(*this); + if (current1 != pos1 || current2 == first2) { + --current1; + } else { + --current2; + } + return temp; + } + SPROUT_CONSTEXPR insert_range_iterator operator+(difference_type n) const { + return advance_impl(n); + } + SPROUT_CONSTEXPR insert_range_iterator operator-(difference_type n) const { + return advance_impl(-n); + } + insert_range_iterator& operator+=(difference_type n) { + insert_range_iterator temp(*this + n); + temp.swap(*this); + return *this; + } + insert_range_iterator& operator-=(difference_type n) { + insert_range_iterator temp(*this - n); + temp.swap(*this); + return *this; + } + SPROUT_CONSTEXPR reference operator[](difference_type n) const { + return *(*this + n); + } + SPROUT_CONSTEXPR insert_range_iterator next() const { + return is_in_base() ? insert_range_iterator(sprout::next(current1), pos1, current2, first2, last2) + : insert_range_iterator(current1, pos1, sprout::next(current2), first2, last2) + ; + } + SPROUT_CONSTEXPR insert_range_iterator prev() const { + return current1 != pos1 || current2 == first2 ? insert_range_iterator(sprout::prev(current1), pos1, current2, first2, last2) + : insert_range_iterator(current1, pos1, sprout::prev(current2), first2, last2) + ; + } + void swap(insert_range_iterator& other) + SPROUT_NOEXCEPT_EXPR( + SPROUT_NOEXCEPT_EXPR(sprout::swap(current1, other.current1)) + && SPROUT_NOEXCEPT_EXPR(sprout::swap(pos1, other.pos1)) + && SPROUT_NOEXCEPT_EXPR(sprout::swap(current2, other.current2)) + && SPROUT_NOEXCEPT_EXPR(sprout::swap(first2, other.first2)) + && SPROUT_NOEXCEPT_EXPR(sprout::swap(last2, other.last2)) + ) + { + sprout::swap(current1, other.current1); + sprout::swap(pos1, other.pos1); + sprout::swap(current2, other.current2); + sprout::swap(first2, other.first2); + sprout::swap(last2, other.last2); + } + }; + + template< + typename DstIterator1, typename SrcIterator1, + typename DstIterator2, typename SrcIterator2 + > + inline SPROUT_CONSTEXPR bool operator==( + sprout::insert_range_iterator const& lhs, + sprout::insert_range_iterator const& rhs + ) + { + return lhs.base() == rhs.base() && lhs.base2() == rhs.base2(); + } + template< + typename DstIterator1, typename SrcIterator1, + typename DstIterator2, typename SrcIterator2 + > + inline SPROUT_CONSTEXPR bool operator!=( + sprout::insert_range_iterator const& lhs, + sprout::insert_range_iterator const& rhs + ) + { + return !(lhs == rhs); + } + template< + typename DstIterator1, typename SrcIterator1, + typename DstIterator2, typename SrcIterator2 + > + inline SPROUT_CONSTEXPR bool operator<( + sprout::insert_range_iterator const& lhs, + sprout::insert_range_iterator const& rhs + ) + { + return lhs.is_in_base() && rhs.is_in_base() ? lhs.base() < rhs.base() + : !lhs.is_in_base() && !rhs.is_in_base() ? lhs.base2() < rhs.base2() + : lhs.is_in_base() + ; + } + template< + typename DstIterator1, typename SrcIterator1, + typename DstIterator2, typename SrcIterator2 + > + inline SPROUT_CONSTEXPR bool operator>( + sprout::insert_range_iterator const& lhs, + sprout::insert_range_iterator const& rhs + ) + { + return rhs < lhs; + } + template< + typename DstIterator1, typename SrcIterator1, + typename DstIterator2, typename SrcIterator2 + > + inline SPROUT_CONSTEXPR bool operator<=( + sprout::insert_range_iterator const& lhs, + sprout::insert_range_iterator const& rhs + ) + { + return !(rhs < lhs); + } + template< + typename DstIterator1, typename SrcIterator1, + typename DstIterator2, typename SrcIterator2 + > + inline SPROUT_CONSTEXPR bool operator>=( + sprout::insert_range_iterator const& lhs, + sprout::insert_range_iterator const& rhs + ) + { + return !(lhs < rhs); + } + template< + typename DstIterator1, typename SrcIterator1, + typename DstIterator2, typename SrcIterator2 + > + inline SPROUT_CONSTEXPR typename sprout::arithmetic_promote< + typename sprout::insert_range_iterator::difference_type, + typename sprout::insert_range_iterator::difference_type + >::type + operator-( + sprout::insert_range_iterator const& lhs, + sprout::insert_range_iterator const& rhs + ) + { + return sprout::limited::plus(lhs.base() - rhs.base(), lhs.base2() - rhs.base2()); + } + template + inline SPROUT_CONSTEXPR sprout::insert_range_iterator operator+( + typename sprout::insert_range_iterator::difference_type n, + sprout::insert_range_iterator const& it + ) + { + return it + n; + } + + // + // make_insert_range_iterator + // + template + inline SPROUT_CONSTEXPR sprout::insert_range_iterator + make_insert_range_iterator(DstIterator it1, DstIterator pos1, SrcIterator it2, SrcIterator first2, SrcIterator last2) { + return sprout::insert_range_iterator(it1, pos1, it2, first2, last2); + } + + // + // swap + // + template + inline void + swap( + sprout::insert_range_iterator& lhs, + sprout::insert_range_iterator& rhs + ) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) + { + lhs.swap(rhs); + } + + // + // iterator_next + // + template + inline SPROUT_CONSTEXPR sprout::insert_range_iterator + iterator_next(sprout::insert_range_iterator const& it) { + return it.next(); + } + + // + // iterator_prev + // + template + inline SPROUT_CONSTEXPR sprout::insert_range_iterator + iterator_prev(sprout::insert_range_iterator const& it) { + return it.prev(); + } +} // namespace sprout + +#endif // #ifndef SPROUT_ITERATOR_INSERT_RANGE_ITERATOR_HPP diff --git a/sprout/iterator/inserter.hpp b/sprout/iterator/inserter.hpp new file mode 100644 index 00000000..8e834d88 --- /dev/null +++ b/sprout/iterator/inserter.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ITERATOR_INSERTER_HPP +#define SPROUT_ITERATOR_INSERTER_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ITERATOR_INSERTER_HPP diff --git a/sprout/iterator/joint_iterator.hpp b/sprout/iterator/joint_iterator.hpp index 5f025cf6..53d56982 100644 --- a/sprout/iterator/joint_iterator.hpp +++ b/sprout/iterator/joint_iterator.hpp @@ -12,7 +12,6 @@ #include #include #include -#include namespace sprout { // @@ -265,8 +264,8 @@ namespace sprout { sprout::joint_iterator const& rhs ) { - return lhs.is_in_left() && rhs.is_in_left() ? rhs.base() - lhs.base() - : !lhs.is_in_left() && !rhs.is_in_left() ? rhs.base2() - lhs.base2() + return lhs.is_in_left() && rhs.is_in_left() ? lhs.base() - rhs.base() + : !lhs.is_in_left() && !rhs.is_in_left() ? lhs.base2() - rhs.base2() : lhs.is_in_left() ? sprout::limited::plus(lhs.left_end() - lhs.base(), rhs.base2() - rhs.right_begin()) : sprout::limited::plus(lhs.base2() - lhs.right_begin(), rhs.left_end() - rhs.base()) ; diff --git a/sprout/iterator/predefined.hpp b/sprout/iterator/predefined.hpp index 990f18c4..e1b04a46 100644 --- a/sprout/iterator/predefined.hpp +++ b/sprout/iterator/predefined.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/sprout/iterator/remake_iterator.hpp b/sprout/iterator/remake_iterator.hpp index e11d2e75..31531730 100644 --- a/sprout/iterator/remake_iterator.hpp +++ b/sprout/iterator/remake_iterator.hpp @@ -71,19 +71,19 @@ namespace sprout { remake_iterator() = default; SPROUT_CONSTEXPR remake_iterator(remake_iterator const& other) : current(other.current), current2(other.current2) - , fst(other.fst) , lst(other.lst) - , begin_off(other.begin_off) , end_off(other.end_off) + , fst(other.fst), lst(other.lst) + , begin_off(other.begin_off), end_off(other.end_off) {} SPROUT_CONSTEXPR remake_iterator(iterator_type it, iterator2_type it2, iterator2_type fst, iterator2_type lst, difference_type begin_off, difference_type end_off) : current(it), current2(it2) , fst(fst), lst(lst) - , begin_off(begin_off) , end_off(end_off) + , begin_off(begin_off), end_off(end_off) {} template SPROUT_CONSTEXPR remake_iterator(remake_iterator const& it) : current(it.base()), current2(it.base2()) , fst(it.first()), lst(it.last()) - , begin_off(it.begin_offset()) , end_off(it.end_offset()) + , begin_off(it.begin_offset()), end_off(it.end_offset()) {} template remake_iterator& operator=(remake_iterator const& it) { diff --git a/sprout/iterator/step_iterator.hpp b/sprout/iterator/step_iterator.hpp index 31f5b836..1b94b37e 100644 --- a/sprout/iterator/step_iterator.hpp +++ b/sprout/iterator/step_iterator.hpp @@ -8,7 +8,6 @@ #include #include #include -#include #include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { diff --git a/sprout/math/bernoulli.hpp b/sprout/math/bernoulli.hpp index 53d40560..5481bf95 100644 --- a/sprout/math/bernoulli.hpp +++ b/sprout/math/bernoulli.hpp @@ -94,7 +94,7 @@ namespace sprout { 1.101191032362797755956e62, \ -2.135525954525350118866e64, \ 4.332889698664119241962e66, \ - -9.18855282416693282262e68 , \ + -9.18855282416693282262e68, \ 2.034689677632907449346e71, \ -4.70038339580357310786e73, \ 1.131804344548424927068e76, \ diff --git a/sprout/numeric/dft/fit/amplitude_spectrum.hpp b/sprout/numeric/dft/fit/amplitude_spectrum.hpp index aece647d..6b1dfda0 100644 --- a/sprout/numeric/dft/fit/amplitude_spectrum.hpp +++ b/sprout/numeric/dft/fit/amplitude_spectrum.hpp @@ -10,7 +10,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -26,7 +25,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::amplitude_spectrum(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/numeric/dft/fit/dft.hpp b/sprout/numeric/dft/fit/dft.hpp index b6ca95e9..a70a02ab 100644 --- a/sprout/numeric/dft/fit/dft.hpp +++ b/sprout/numeric/dft/fit/dft.hpp @@ -10,7 +10,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -25,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::dft(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/numeric/dft/fit/idft.hpp b/sprout/numeric/dft/fit/idft.hpp index 4c598c66..3549fde1 100644 --- a/sprout/numeric/dft/fit/idft.hpp +++ b/sprout/numeric/dft/fit/idft.hpp @@ -10,7 +10,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace fit { @@ -25,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::idft(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/numeric/dft/fit/phase_spectrum.hpp b/sprout/numeric/dft/fit/phase_spectrum.hpp index e2b6166f..63ed8d2b 100644 --- a/sprout/numeric/dft/fit/phase_spectrum.hpp +++ b/sprout/numeric/dft/fit/phase_spectrum.hpp @@ -10,7 +10,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -26,7 +25,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::phase_spectrum(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/numeric/fit/adjacent_difference.hpp b/sprout/numeric/fit/adjacent_difference.hpp index f4ac4324..b8bce079 100644 --- a/sprout/numeric/fit/adjacent_difference.hpp +++ b/sprout/numeric/fit/adjacent_difference.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -25,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::adjacent_difference(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/numeric/fit/partial_sum.hpp b/sprout/numeric/fit/partial_sum.hpp index e65abe38..111bde76 100644 --- a/sprout/numeric/fit/partial_sum.hpp +++ b/sprout/numeric/fit/partial_sum.hpp @@ -9,7 +9,6 @@ #include #include #include -#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT #include namespace sprout { @@ -25,7 +24,7 @@ namespace sprout { return sprout::sub_copy( sprout::get_internal(sprout::fixed::partial_sum(first, last, result)), offset, - offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + offset + sprout::fit_size(result, sprout::distance(first, last)) ); } } // namespace detail diff --git a/sprout/random/uniform_smallint.hpp b/sprout/random/uniform_smallint.hpp index 7fac93d0..049bdbdf 100644 --- a/sprout/random/uniform_smallint.hpp +++ b/sprout/random/uniform_smallint.hpp @@ -166,7 +166,7 @@ namespace sprout { *this ) : sprout::random::random_result( - sprout::random::detail::add()(offset , min_), + sprout::random::detail::add()(offset, min_), rnd.engine(), *this ) diff --git a/sprout/rational/rational.hpp b/sprout/rational/rational.hpp index 85c23173..fb431504 100644 --- a/sprout/rational/rational.hpp +++ b/sprout/rational/rational.hpp @@ -35,17 +35,17 @@ namespace sprout { IntType den_; protected: SPROUT_CONSTEXPR rational_impl() - : num_(0) , den_(1) + : num_(0), den_(1) {} rational_impl(rational_impl const&) = default; SPROUT_CONSTEXPR rational_impl(param_type n) - : num_(n) , den_(1) + : num_(n), den_(1) {} SPROUT_CONSTEXPR rational_impl(param_type n, param_type d) - : num_(n) , den_(d) + : num_(n), den_(d) {} SPROUT_CONSTEXPR rational_impl(param_type n, param_type d, param_type g) - : num_(n / g) , den_(d / g) + : num_(n / g), den_(d / g) {} }; } // namespace detail diff --git a/sprout/sub_array/sub_array.hpp b/sprout/sub_array/sub_array.hpp index 995f3eec..65a014d6 100644 --- a/sprout/sub_array/sub_array.hpp +++ b/sprout/sub_array/sub_array.hpp @@ -217,7 +217,7 @@ namespace sprout { last ) {} - SPROUT_CONSTEXPR sub_array(sub_array const& other, const_iterator first, const_iterator last) + SPROUT_CONSTEXPR sub_array(sub_array const& other, const_iterator first, const_iterator last) : impl_type( array_tag(), impl_type::template to_param(other.array_), @@ -226,7 +226,7 @@ namespace sprout { sprout::distance(sprout::begin(other.get_array()), last) ) {} - SPROUT_CONSTEXPR sub_array(sub_array const& other, difference_type first, difference_type last) + SPROUT_CONSTEXPR sub_array(sub_array const& other, difference_type first, difference_type last) : impl_type( array_tag(), impl_type::template to_param(other.array_), @@ -316,14 +316,14 @@ namespace sprout { } // others: template - sub_array& operator=(sub_array const& rhs) { + sub_array& operator=(sub_array const& rhs) { array_ = rhs.array_; first_ = rhs.first_; last_ = rhs.last_; return *this; } template - sub_array& operator=(sub_array&& rhs) { + sub_array& operator=(sub_array&& rhs) { array_ = std::move(rhs.array_); first_ = std::move(rhs.first_); last_ = std::move(rhs.last_);