From 899bf3fa777ea7f90daa0984154fab2d62f35bef Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Tue, 26 Feb 2013 16:14:04 +0900 Subject: [PATCH] add sub_window, add sub_offset --- sprout/algorithm/adjacent_find.hpp | 2 +- sprout/algorithm/all_of.hpp | 2 +- sprout/algorithm/all_of_equal.hpp | 2 +- sprout/algorithm/any_of.hpp | 2 +- sprout/algorithm/any_of_equal.hpp | 2 +- sprout/algorithm/count.hpp | 2 +- sprout/algorithm/count_if.hpp | 2 +- sprout/algorithm/find.hpp | 2 +- sprout/algorithm/find_end.hpp | 2 +- sprout/algorithm/find_first_of.hpp | 2 +- sprout/algorithm/find_if.hpp | 2 +- sprout/algorithm/find_if_not.hpp | 2 +- sprout/algorithm/fit/clamp_range_copy.hpp | 2 +- sprout/algorithm/fit/copy.hpp | 2 +- sprout/algorithm/fit/copy_if.hpp | 2 +- sprout/algorithm/fit/copy_until.hpp | 2 +- sprout/algorithm/fit/copy_while.hpp | 2 +- sprout/algorithm/fit/merge.hpp | 2 +- sprout/algorithm/fit/partition_copy.hpp | 2 +- sprout/algorithm/fit/remove_copy.hpp | 2 +- sprout/algorithm/fit/remove_copy_if.hpp | 2 +- sprout/algorithm/fit/replace_copy.hpp | 2 +- sprout/algorithm/fit/replace_copy_if.hpp | 2 +- sprout/algorithm/fit/set_difference.hpp | 2 +- sprout/algorithm/fit/set_intersection.hpp | 2 +- .../fit/set_symmetric_difference.hpp | 2 +- sprout/algorithm/fit/set_union.hpp | 2 +- .../algorithm/fit/stable_partition_copy.hpp | 2 +- sprout/algorithm/fit/transform.hpp | 2 +- sprout/algorithm/fit/unique_copy.hpp | 2 +- sprout/algorithm/fixed/copy_n.hpp | 2 +- sprout/algorithm/fixed/unique_copy.hpp | 2 +- sprout/algorithm/includes.hpp | 2 +- sprout/algorithm/is_partitioned.hpp | 2 +- sprout/algorithm/is_sorted.hpp | 2 +- sprout/algorithm/is_sorted_until.hpp | 2 +- sprout/algorithm/lexicographical_compare.hpp | 2 +- sprout/algorithm/max_element.hpp | 2 +- sprout/algorithm/min_element.hpp | 2 +- sprout/algorithm/minmax_element.hpp | 2 +- sprout/algorithm/none_of.hpp | 2 +- sprout/algorithm/none_of_equal.hpp | 2 +- sprout/algorithm/one_of.hpp | 2 +- sprout/algorithm/one_of_equal.hpp | 2 +- sprout/algorithm/search.hpp | 2 +- sprout/algorithm/string/join.hpp | 2 +- .../tristate_lexicographical_compare.hpp | 2 +- .../container/container_construct_traits.hpp | 2 +- sprout/detail/algorithm/count_n.hpp | 2 +- sprout/detail/algorithm/count_n_if.hpp | 2 +- sprout/detail/algorithm/overlap_count.hpp | 2 +- sprout/detail/algorithm/set_overlap_count.hpp | 2 +- sprout/iterator/distance.hpp | 2 +- sprout/iterator/type_traits.hpp | 2 +- sprout/iterator/type_traits/category.hpp | 10 + sprout/iterator/type_traits/common.hpp | 2 +- .../is_constant_distance_iterator.hpp | 22 +++ sprout/iterator/type_traits/is_iterator.hpp | 115 +----------- .../type_traits/is_iterator_category_of.hpp | 54 ++++++ .../iterator/type_traits/is_iterator_of.hpp | 70 +++++++ sprout/numeric/accumulate.hpp | 2 +- sprout/numeric/dft/fit/amplitude_spectrum.hpp | 2 +- sprout/numeric/dft/fit/phase_spectrum.hpp | 2 +- sprout/numeric/fit/adjacent_difference.hpp | 2 +- sprout/numeric/fit/partial_sum.hpp | 2 +- sprout/numeric/inner_product.hpp | 2 +- sprout/range/adaptor/offset.hpp | 22 +-- sprout/sub_array.hpp | 2 + sprout/sub_array/sub.hpp | 167 +++++------------ sprout/sub_array/sub_array.hpp | 102 +++++----- sprout/sub_array/sub_offset.hpp | 103 +++++++++++ sprout/sub_array/sub_window.hpp | 174 ++++++++++++++++++ 72 files changed, 610 insertions(+), 353 deletions(-) create mode 100644 sprout/iterator/type_traits/category.hpp create mode 100644 sprout/iterator/type_traits/is_constant_distance_iterator.hpp create mode 100644 sprout/iterator/type_traits/is_iterator_category_of.hpp create mode 100644 sprout/iterator/type_traits/is_iterator_of.hpp create mode 100644 sprout/sub_array/sub_offset.hpp create mode 100644 sprout/sub_array/sub_window.hpp diff --git a/sprout/algorithm/adjacent_find.hpp b/sprout/algorithm/adjacent_find.hpp index 9a41503c..4cfb4f3e 100644 --- a/sprout/algorithm/adjacent_find.hpp +++ b/sprout/algorithm/adjacent_find.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT diff --git a/sprout/algorithm/all_of.hpp b/sprout/algorithm/all_of.hpp index b3922134..44b91d6f 100644 --- a/sprout/algorithm/all_of.hpp +++ b/sprout/algorithm/all_of.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/all_of_equal.hpp b/sprout/algorithm/all_of_equal.hpp index 6bfa6e02..c431beb5 100644 --- a/sprout/algorithm/all_of_equal.hpp +++ b/sprout/algorithm/all_of_equal.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/any_of.hpp b/sprout/algorithm/any_of.hpp index 98f2549d..b30db898 100644 --- a/sprout/algorithm/any_of.hpp +++ b/sprout/algorithm/any_of.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/any_of_equal.hpp b/sprout/algorithm/any_of_equal.hpp index f3a9c81f..d1382b51 100644 --- a/sprout/algorithm/any_of_equal.hpp +++ b/sprout/algorithm/any_of_equal.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/count.hpp b/sprout/algorithm/count.hpp index 4d57c15d..311f9282 100644 --- a/sprout/algorithm/count.hpp +++ b/sprout/algorithm/count.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/count_if.hpp b/sprout/algorithm/count_if.hpp index 3bb2968c..c2efa57b 100644 --- a/sprout/algorithm/count_if.hpp +++ b/sprout/algorithm/count_if.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/find.hpp b/sprout/algorithm/find.hpp index 7acd117b..687c2b4d 100644 --- a/sprout/algorithm/find.hpp +++ b/sprout/algorithm/find.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/find_end.hpp b/sprout/algorithm/find_end.hpp index 5da0066b..be7ab0aa 100644 --- a/sprout/algorithm/find_end.hpp +++ b/sprout/algorithm/find_end.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/algorithm/find_first_of.hpp b/sprout/algorithm/find_first_of.hpp index 060d234e..53027fe2 100644 --- a/sprout/algorithm/find_first_of.hpp +++ b/sprout/algorithm/find_first_of.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/algorithm/find_if.hpp b/sprout/algorithm/find_if.hpp index e6356d97..4ce01c3a 100644 --- a/sprout/algorithm/find_if.hpp +++ b/sprout/algorithm/find_if.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/find_if_not.hpp b/sprout/algorithm/find_if_not.hpp index 0d97c045..9541b7c8 100644 --- a/sprout/algorithm/find_if_not.hpp +++ b/sprout/algorithm/find_if_not.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/fit/clamp_range_copy.hpp b/sprout/algorithm/fit/clamp_range_copy.hpp index 105c75cf..7ce5ddde 100644 --- a/sprout/algorithm/fit/clamp_range_copy.hpp +++ b/sprout/algorithm/fit/clamp_range_copy.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/copy.hpp b/sprout/algorithm/fit/copy.hpp index 6f2558e1..03a8fc22 100644 --- a/sprout/algorithm/fit/copy.hpp +++ b/sprout/algorithm/fit/copy.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/copy_if.hpp b/sprout/algorithm/fit/copy_if.hpp index db3eaf31..350e231d 100644 --- a/sprout/algorithm/fit/copy_if.hpp +++ b/sprout/algorithm/fit/copy_if.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/copy_until.hpp b/sprout/algorithm/fit/copy_until.hpp index 6706478c..80ad7e34 100644 --- a/sprout/algorithm/fit/copy_until.hpp +++ b/sprout/algorithm/fit/copy_until.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/copy_while.hpp b/sprout/algorithm/fit/copy_while.hpp index 6d84ff84..1250cc0f 100644 --- a/sprout/algorithm/fit/copy_while.hpp +++ b/sprout/algorithm/fit/copy_while.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/merge.hpp b/sprout/algorithm/fit/merge.hpp index b0f1082c..1c6cf20e 100644 --- a/sprout/algorithm/fit/merge.hpp +++ b/sprout/algorithm/fit/merge.hpp @@ -9,7 +9,7 @@ #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 45229171..e4ea84fc 100644 --- a/sprout/algorithm/fit/partition_copy.hpp +++ b/sprout/algorithm/fit/partition_copy.hpp @@ -11,7 +11,7 @@ #include #include #include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/remove_copy.hpp b/sprout/algorithm/fit/remove_copy.hpp index 6cbc9d13..6683f39e 100644 --- a/sprout/algorithm/fit/remove_copy.hpp +++ b/sprout/algorithm/fit/remove_copy.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/remove_copy_if.hpp b/sprout/algorithm/fit/remove_copy_if.hpp index 0aa024a1..d87a01aa 100644 --- a/sprout/algorithm/fit/remove_copy_if.hpp +++ b/sprout/algorithm/fit/remove_copy_if.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/replace_copy.hpp b/sprout/algorithm/fit/replace_copy.hpp index 535f1c17..a3730cb4 100644 --- a/sprout/algorithm/fit/replace_copy.hpp +++ b/sprout/algorithm/fit/replace_copy.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/replace_copy_if.hpp b/sprout/algorithm/fit/replace_copy_if.hpp index 55d6eade..3ce5b561 100644 --- a/sprout/algorithm/fit/replace_copy_if.hpp +++ b/sprout/algorithm/fit/replace_copy_if.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/set_difference.hpp b/sprout/algorithm/fit/set_difference.hpp index 4c16507d..568d2bf0 100644 --- a/sprout/algorithm/fit/set_difference.hpp +++ b/sprout/algorithm/fit/set_difference.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/set_intersection.hpp b/sprout/algorithm/fit/set_intersection.hpp index 9643b6d6..94cdee22 100644 --- a/sprout/algorithm/fit/set_intersection.hpp +++ b/sprout/algorithm/fit/set_intersection.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/set_symmetric_difference.hpp b/sprout/algorithm/fit/set_symmetric_difference.hpp index 40194506..a69aa505 100644 --- a/sprout/algorithm/fit/set_symmetric_difference.hpp +++ b/sprout/algorithm/fit/set_symmetric_difference.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/set_union.hpp b/sprout/algorithm/fit/set_union.hpp index 24f63560..b884fa37 100644 --- a/sprout/algorithm/fit/set_union.hpp +++ b/sprout/algorithm/fit/set_union.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/stable_partition_copy.hpp b/sprout/algorithm/fit/stable_partition_copy.hpp index 79c90f65..268ec802 100644 --- a/sprout/algorithm/fit/stable_partition_copy.hpp +++ b/sprout/algorithm/fit/stable_partition_copy.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/transform.hpp b/sprout/algorithm/fit/transform.hpp index d37263f0..068b8318 100644 --- a/sprout/algorithm/fit/transform.hpp +++ b/sprout/algorithm/fit/transform.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fit/unique_copy.hpp b/sprout/algorithm/fit/unique_copy.hpp index 15962848..91463a19 100644 --- a/sprout/algorithm/fit/unique_copy.hpp +++ b/sprout/algorithm/fit/unique_copy.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/algorithm/fixed/copy_n.hpp b/sprout/algorithm/fixed/copy_n.hpp index 366b9c8d..18bf8a6c 100644 --- a/sprout/algorithm/fixed/copy_n.hpp +++ b/sprout/algorithm/fixed/copy_n.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace sprout { namespace fixed { diff --git a/sprout/algorithm/fixed/unique_copy.hpp b/sprout/algorithm/fixed/unique_copy.hpp index fe6e0f41..b9e27e5c 100644 --- a/sprout/algorithm/fixed/unique_copy.hpp +++ b/sprout/algorithm/fixed/unique_copy.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fixed { diff --git a/sprout/algorithm/includes.hpp b/sprout/algorithm/includes.hpp index bf0af765..c971c70a 100644 --- a/sprout/algorithm/includes.hpp +++ b/sprout/algorithm/includes.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/sprout/algorithm/is_partitioned.hpp b/sprout/algorithm/is_partitioned.hpp index 3a037e68..ff6e1498 100644 --- a/sprout/algorithm/is_partitioned.hpp +++ b/sprout/algorithm/is_partitioned.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/algorithm/is_sorted.hpp b/sprout/algorithm/is_sorted.hpp index 6f69e56f..a8b55a1a 100644 --- a/sprout/algorithm/is_sorted.hpp +++ b/sprout/algorithm/is_sorted.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT diff --git a/sprout/algorithm/is_sorted_until.hpp b/sprout/algorithm/is_sorted_until.hpp index ef46c92c..5582ae5e 100644 --- a/sprout/algorithm/is_sorted_until.hpp +++ b/sprout/algorithm/is_sorted_until.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT diff --git a/sprout/algorithm/lexicographical_compare.hpp b/sprout/algorithm/lexicographical_compare.hpp index fcc23f47..08fc9d06 100644 --- a/sprout/algorithm/lexicographical_compare.hpp +++ b/sprout/algorithm/lexicographical_compare.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/algorithm/max_element.hpp b/sprout/algorithm/max_element.hpp index 37d1ad7c..b7f59097 100644 --- a/sprout/algorithm/max_element.hpp +++ b/sprout/algorithm/max_element.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT diff --git a/sprout/algorithm/min_element.hpp b/sprout/algorithm/min_element.hpp index 7523168f..5c3ecda7 100644 --- a/sprout/algorithm/min_element.hpp +++ b/sprout/algorithm/min_element.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT diff --git a/sprout/algorithm/minmax_element.hpp b/sprout/algorithm/minmax_element.hpp index 10417972..d3d1d49c 100644 --- a/sprout/algorithm/minmax_element.hpp +++ b/sprout/algorithm/minmax_element.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT diff --git a/sprout/algorithm/none_of.hpp b/sprout/algorithm/none_of.hpp index 6cfae9aa..33a8fd95 100644 --- a/sprout/algorithm/none_of.hpp +++ b/sprout/algorithm/none_of.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/none_of_equal.hpp b/sprout/algorithm/none_of_equal.hpp index edaa2165..7cf7f511 100644 --- a/sprout/algorithm/none_of_equal.hpp +++ b/sprout/algorithm/none_of_equal.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/one_of.hpp b/sprout/algorithm/one_of.hpp index 60fd6283..8f96e7bc 100644 --- a/sprout/algorithm/one_of.hpp +++ b/sprout/algorithm/one_of.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/one_of_equal.hpp b/sprout/algorithm/one_of_equal.hpp index 094d702d..2fad7b0c 100644 --- a/sprout/algorithm/one_of_equal.hpp +++ b/sprout/algorithm/one_of_equal.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/algorithm/search.hpp b/sprout/algorithm/search.hpp index 8941216e..143225cd 100644 --- a/sprout/algorithm/search.hpp +++ b/sprout/algorithm/search.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/algorithm/string/join.hpp b/sprout/algorithm/string/join.hpp index 9e12feb7..370a66fa 100644 --- a/sprout/algorithm/string/join.hpp +++ b/sprout/algorithm/string/join.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/algorithm/tristate_lexicographical_compare.hpp b/sprout/algorithm/tristate_lexicographical_compare.hpp index ba96c174..548cbbc0 100644 --- a/sprout/algorithm/tristate_lexicographical_compare.hpp +++ b/sprout/algorithm/tristate_lexicographical_compare.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/container/container_construct_traits.hpp b/sprout/container/container_construct_traits.hpp index 6e814c9f..e3408bee 100644 --- a/sprout/container/container_construct_traits.hpp +++ b/sprout/container/container_construct_traits.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/sprout/detail/algorithm/count_n.hpp b/sprout/detail/algorithm/count_n.hpp index 3f26f3ce..fefeaef3 100644 --- a/sprout/detail/algorithm/count_n.hpp +++ b/sprout/detail/algorithm/count_n.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/sprout/detail/algorithm/count_n_if.hpp b/sprout/detail/algorithm/count_n_if.hpp index d7cb6404..139bbac6 100644 --- a/sprout/detail/algorithm/count_n_if.hpp +++ b/sprout/detail/algorithm/count_n_if.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/sprout/detail/algorithm/overlap_count.hpp b/sprout/detail/algorithm/overlap_count.hpp index 2323a4bf..3afbe712 100644 --- a/sprout/detail/algorithm/overlap_count.hpp +++ b/sprout/detail/algorithm/overlap_count.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT diff --git a/sprout/detail/algorithm/set_overlap_count.hpp b/sprout/detail/algorithm/set_overlap_count.hpp index d55ebf93..ef5d12d0 100644 --- a/sprout/detail/algorithm/set_overlap_count.hpp +++ b/sprout/detail/algorithm/set_overlap_count.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/iterator/distance.hpp b/sprout/iterator/distance.hpp index e66559a2..942bc0a2 100644 --- a/sprout/iterator/distance.hpp +++ b/sprout/iterator/distance.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/sprout/iterator/type_traits.hpp b/sprout/iterator/type_traits.hpp index 6e63ae1a..0f6b1e66 100644 --- a/sprout/iterator/type_traits.hpp +++ b/sprout/iterator/type_traits.hpp @@ -2,7 +2,7 @@ #define SPROUT_ITERATOR_TYPE_TRAITS_HPP #include -#include +#include #include #endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_HPP diff --git a/sprout/iterator/type_traits/category.hpp b/sprout/iterator/type_traits/category.hpp new file mode 100644 index 00000000..60fd219d --- /dev/null +++ b/sprout/iterator/type_traits/category.hpp @@ -0,0 +1,10 @@ +#ifndef SPROUT_ITERATOR_TYPE_TRAITS_CATEGORY_HPP +#define SPROUT_ITERATOR_TYPE_TRAITS_CATEGORY_HPP + +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_CATEGORY_HPP diff --git a/sprout/iterator/type_traits/common.hpp b/sprout/iterator/type_traits/common.hpp index b7e228b9..8e66e5dd 100644 --- a/sprout/iterator/type_traits/common.hpp +++ b/sprout/iterator/type_traits/common.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace sprout { namespace detail { diff --git a/sprout/iterator/type_traits/is_constant_distance_iterator.hpp b/sprout/iterator/type_traits/is_constant_distance_iterator.hpp new file mode 100644 index 00000000..e797756b --- /dev/null +++ b/sprout/iterator/type_traits/is_constant_distance_iterator.hpp @@ -0,0 +1,22 @@ +#ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_CONSTANT_DISTANCE_ITERATOR_HPP +#define SPROUT_ITERATOR_TYPE_TRAITS_IS_CONSTANT_DISTANCE_ITERATOR_HPP + +#include +#include +#include + +namespace sprout { + + // + // is_constant_distance_iterator + // + template + struct is_constant_distance_iterator + : public std::integral_constant< + bool, + sprout::is_random_access_iterator::value && !std::is_pointer::value + > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_CONSTANT_DISTANCE_ITERATOR_HPP diff --git a/sprout/iterator/type_traits/is_iterator.hpp b/sprout/iterator/type_traits/is_iterator.hpp index 4f9c4bf2..01e88c7e 100644 --- a/sprout/iterator/type_traits/is_iterator.hpp +++ b/sprout/iterator/type_traits/is_iterator.hpp @@ -2,7 +2,6 @@ #define SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_HPP #include -#include #include #include @@ -13,6 +12,7 @@ namespace sprout { // SPROUT_HAS_XXX_TYPE_DEF_LAZY(iterator_category); } // namespace detail + // // is_iterator // @@ -20,119 +20,6 @@ namespace sprout { struct is_iterator : public sprout::detail::has_iterator_category > {}; - - // - // is_iterator_category_of - // - template - struct is_iterator_category_of - : public std::is_convertible - {}; - - // - // is_input_iterator_category - // - template - struct is_input_iterator_category - : public sprout::is_iterator_category_of - {}; - // - // is_output_iterator_category - // - template - struct is_output_iterator_category - : public sprout::is_iterator_category_of - {}; - // - // is_forward_iterator_category - // - template - struct is_forward_iterator_category - : public sprout::is_iterator_category_of - {}; - // - // is_bidirectional_iterator_category - // - template - struct is_bidirectional_iterator_category - : public sprout::is_iterator_category_of - {}; - // - // is_random_access_iterator_category - // - template - struct is_random_access_iterator_category - : public sprout::is_iterator_category_of - {}; - - namespace detail { - template - struct is_iterator_of_impl - : public std::false_type - {}; - template - struct is_iterator_of_impl< - MaybeIterator, Category, - typename std::enable_if::value>::type - > - : public sprout::is_iterator_category_of::iterator_category, Category> - {}; - } // namespace detail - - // - // is_iterator_of - // - template - struct is_iterator_of - : public sprout::detail::is_iterator_of_impl - {}; - - // - // is_input_iterator - // - template - struct is_input_iterator - : public sprout::is_iterator_of - {}; - // - // is_output_iterator - // - template - struct is_output_iterator - : public sprout::is_iterator_of - {}; - // - // is_forward_iterator - // - template - struct is_forward_iterator - : public sprout::is_iterator_of - {}; - // - // is_bidirectional_iterator - // - template - struct is_bidirectional_iterator - : public sprout::is_iterator_of - {}; - // - // is_random_access_iterator - // - template - struct is_random_access_iterator - : public sprout::is_iterator_of - {}; - - // - // is_constant_distance_iterator - // - template - struct is_constant_distance_iterator - : public std::integral_constant< - bool, - sprout::is_random_access_iterator::value && !std::is_pointer::value - > - {}; } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_HPP diff --git a/sprout/iterator/type_traits/is_iterator_category_of.hpp b/sprout/iterator/type_traits/is_iterator_category_of.hpp new file mode 100644 index 00000000..4f1e79b7 --- /dev/null +++ b/sprout/iterator/type_traits/is_iterator_category_of.hpp @@ -0,0 +1,54 @@ +#ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_CATEGORY_OF_HPP +#define SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_CATEGORY_OF_HPP + +#include +#include +#include + +namespace sprout { + // + // is_iterator_category_of + // + template + struct is_iterator_category_of + : public std::is_convertible + {}; + + // + // is_input_iterator_category + // + template + struct is_input_iterator_category + : public sprout::is_iterator_category_of + {}; + // + // is_output_iterator_category + // + template + struct is_output_iterator_category + : public sprout::is_iterator_category_of + {}; + // + // is_forward_iterator_category + // + template + struct is_forward_iterator_category + : public sprout::is_iterator_category_of + {}; + // + // is_bidirectional_iterator_category + // + template + struct is_bidirectional_iterator_category + : public sprout::is_iterator_category_of + {}; + // + // is_random_access_iterator_category + // + template + struct is_random_access_iterator_category + : public sprout::is_iterator_category_of + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_CATEGORY_OF_HPP diff --git a/sprout/iterator/type_traits/is_iterator_of.hpp b/sprout/iterator/type_traits/is_iterator_of.hpp new file mode 100644 index 00000000..2dbcfa66 --- /dev/null +++ b/sprout/iterator/type_traits/is_iterator_of.hpp @@ -0,0 +1,70 @@ +#ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_OF_HPP +#define SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_OF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template + struct is_iterator_of_impl + : public std::false_type + {}; + template + struct is_iterator_of_impl< + MaybeIterator, Category, + typename std::enable_if::value>::type + > + : public sprout::is_iterator_category_of::iterator_category, Category> + {}; + } // namespace detail + + // + // is_iterator_of + // + template + struct is_iterator_of + : public sprout::detail::is_iterator_of_impl + {}; + + // + // is_input_iterator + // + template + struct is_input_iterator + : public sprout::is_iterator_of + {}; + // + // is_output_iterator + // + template + struct is_output_iterator + : public sprout::is_iterator_of + {}; + // + // is_forward_iterator + // + template + struct is_forward_iterator + : public sprout::is_iterator_of + {}; + // + // is_bidirectional_iterator + // + template + struct is_bidirectional_iterator + : public sprout::is_iterator_of + {}; + // + // is_random_access_iterator + // + template + struct is_random_access_iterator + : public sprout::is_iterator_of + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_OF_HPP diff --git a/sprout/numeric/accumulate.hpp b/sprout/numeric/accumulate.hpp index c23ec1f2..f97010d2 100644 --- a/sprout/numeric/accumulate.hpp +++ b/sprout/numeric/accumulate.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/sprout/numeric/dft/fit/amplitude_spectrum.hpp b/sprout/numeric/dft/fit/amplitude_spectrum.hpp index 6b1dfda0..35b144a3 100644 --- a/sprout/numeric/dft/fit/amplitude_spectrum.hpp +++ b/sprout/numeric/dft/fit/amplitude_spectrum.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/numeric/dft/fit/phase_spectrum.hpp b/sprout/numeric/dft/fit/phase_spectrum.hpp index 63ed8d2b..0a26282c 100644 --- a/sprout/numeric/dft/fit/phase_spectrum.hpp +++ b/sprout/numeric/dft/fit/phase_spectrum.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/numeric/fit/adjacent_difference.hpp b/sprout/numeric/fit/adjacent_difference.hpp index b8bce079..a12de0e7 100644 --- a/sprout/numeric/fit/adjacent_difference.hpp +++ b/sprout/numeric/fit/adjacent_difference.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/numeric/fit/partial_sum.hpp b/sprout/numeric/fit/partial_sum.hpp index 111bde76..939d61c4 100644 --- a/sprout/numeric/fit/partial_sum.hpp +++ b/sprout/numeric/fit/partial_sum.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace sprout { namespace fit { diff --git a/sprout/numeric/inner_product.hpp b/sprout/numeric/inner_product.hpp index 3b516c05..1eff744a 100644 --- a/sprout/numeric/inner_product.hpp +++ b/sprout/numeric/inner_product.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/range/adaptor/offset.hpp b/sprout/range/adaptor/offset.hpp index 3454bf1b..19ec1da1 100644 --- a/sprout/range/adaptor/offset.hpp +++ b/sprout/range/adaptor/offset.hpp @@ -88,18 +88,18 @@ namespace sprout { return sprout::adaptors::detail::adapted_range_default< typename std::remove_reference::type>::type >( - sprout::next( - sprout::begin(sprout::lvalue_forward(lhs)), - NS_SSCRISK_CEL_OR_SPROUT::min(rhs.from_begin(), sprout::size(sprout::lvalue_forward(lhs))) - ), - sprout::next( - sprout::end(sprout::lvalue_forward(lhs)), - NS_SSCRISK_CEL_OR_SPROUT::max( - rhs.from_end(), - NS_SSCRISK_CEL_OR_SPROUT::min(rhs.from_begin() - sprout::size(sprout::lvalue_forward(lhs)), 0) - ) + sprout::next( + sprout::begin(sprout::lvalue_forward(lhs)), + NS_SSCRISK_CEL_OR_SPROUT::min(rhs.from_begin(), sprout::size(sprout::lvalue_forward(lhs))) + ), + sprout::next( + sprout::end(sprout::lvalue_forward(lhs)), + NS_SSCRISK_CEL_OR_SPROUT::max( + rhs.from_end(), + NS_SSCRISK_CEL_OR_SPROUT::min(rhs.from_begin() - sprout::size(sprout::lvalue_forward(lhs)), 0) ) - ); + ) + ); } template inline SPROUT_CONSTEXPR sprout::adaptors::detail::adapted_range_default< diff --git a/sprout/sub_array.hpp b/sprout/sub_array.hpp index 236b2f64..85ece5f1 100644 --- a/sprout/sub_array.hpp +++ b/sprout/sub_array.hpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #endif // #ifndef SPROUT_SUB_ARRAY_HPP diff --git a/sprout/sub_array/sub.hpp b/sprout/sub_array/sub.hpp index a95f684c..f4af89f7 100644 --- a/sprout/sub_array/sub.hpp +++ b/sprout/sub_array/sub.hpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace sprout { // @@ -24,16 +25,6 @@ namespace sprout { } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type - sub( - Container& arr, - typename sprout::container_traits >::difference_type first, - typename sprout::container_traits >::difference_type last - ) - { - return sprout::sub_array(arr, first, last); - } - template - inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub( Container& arr, typename sprout::container_traits >::const_iterator first @@ -45,22 +36,22 @@ namespace sprout { inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub( Container& arr, - typename sprout::container_traits >::difference_type first + typename sprout::container_traits >::difference_type to_first, + typename sprout::container_traits >::difference_type to_last ) { - return sprout::sub(arr, first, sprout::size(arr)); + return sprout::sub_window(arr, to_first, to_last); } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub( - Container& arr + Container& arr, + typename sprout::container_traits >::difference_type to_first = 0 ) { - return sprout::sub(arr, sprout::begin(arr), sprout::end(arr)); + return sprout::sub_window(arr, to_first); } - // - // sub - // + template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub( @@ -73,16 +64,6 @@ namespace sprout { } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type - sub( - Container const& arr, - typename sprout::container_traits >::difference_type first, - typename sprout::container_traits >::difference_type last - ) - { - return sprout::sub_array(arr, first, last); - } - template - inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub( Container const& arr, typename sprout::container_traits >::const_iterator first @@ -94,22 +75,22 @@ namespace sprout { inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub( Container const& arr, - typename sprout::container_traits >::difference_type first + typename sprout::container_traits >::difference_type to_first, + typename sprout::container_traits >::difference_type to_last ) { - return sprout::sub(arr, first, sprout::size(arr)); + return sprout::sub_window(arr, to_first, to_last); } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub( - Container const& arr + Container const& arr, + typename sprout::container_traits >::difference_type to_first = 0 ) { - return sprout::sub(arr, sprout::begin(arr), sprout::end(arr)); + return sprout::sub_window(arr, to_first); } - // - // sub - // + template inline SPROUT_CONSTEXPR typename std::enable_if::value, Container>::type sub( @@ -122,16 +103,6 @@ namespace sprout { } template inline SPROUT_CONSTEXPR typename std::enable_if::value, Container>::type - sub( - Container const& arr, - typename sprout::container_traits::difference_type first, - typename sprout::container_traits::difference_type last - ) - { - return Container(arr, first, last); - } - template - inline SPROUT_CONSTEXPR typename std::enable_if::value, Container>::type sub( Container const& arr, typename sprout::container_traits::const_iterator first @@ -143,18 +114,20 @@ namespace sprout { inline SPROUT_CONSTEXPR typename std::enable_if::value, Container>::type sub( Container const& arr, - typename sprout::container_traits::difference_type first + typename sprout::container_traits::difference_type to_first, + typename sprout::container_traits::difference_type to_last ) { - return sprout::sub(arr, first, sprout::size(arr)); + return sprout::sub_window(arr, to_first, to_last); } template inline SPROUT_CONSTEXPR typename std::enable_if::value, Container>::type sub( - Container const& arr + Container const& arr, + typename sprout::container_traits::difference_type to_first = 0 ) { - return sprout::sub(arr, sprout::begin(arr), sprout::end(arr)); + return sprout::sub_window(arr, to_first); } // @@ -172,16 +145,6 @@ namespace sprout { } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type - csub( - Container const& arr, - typename sprout::container_traits >::difference_type first, - typename sprout::container_traits >::difference_type last - ) - { - return sprout::sub_array(arr, first, last); - } - template - inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type csub( Container const& arr, typename sprout::container_traits >::const_iterator first @@ -193,22 +156,22 @@ namespace sprout { inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type csub( Container const& arr, - typename sprout::container_traits >::difference_type first + typename sprout::container_traits >::difference_type to_first, + typename sprout::container_traits >::difference_type to_last ) { - return sprout::csub(arr, first, sprout::size(arr)); + return sprout::csub_window(arr, to_first, to_last); } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type csub( - Container const& arr + Container const& arr, + typename sprout::container_traits >::difference_type to_first = 0 ) { - return sprout::csub(arr, sprout::begin(arr), sprout::end(arr)); + return sprout::csub_window(arr, to_first); } - // - // csub - // + template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type csub( @@ -221,20 +184,6 @@ namespace sprout { } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type - csub( - Container const& arr, - typename sprout::container_traits::difference_type first, - typename sprout::container_traits::difference_type last - ) - { - return sprout::sub_array( - arr.get_array(), - sprout::next(sprout::begin(arr), first), - sprout::next(sprout::begin(arr), last) - ); - } - template - inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type csub( Container const& arr, typename sprout::container_traits::const_iterator first @@ -246,18 +195,20 @@ namespace sprout { inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type csub( Container const& arr, - typename sprout::container_traits::difference_type first + typename sprout::container_traits::difference_type to_first, + typename sprout::container_traits::difference_type to_last ) { - return sprout::csub(arr, first, sprout::size(arr)); + return sprout::csub_window(arr, to_first, to_last); } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type csub( - Container const& arr + Container const& arr, + typename sprout::container_traits::difference_type to_first = 0 ) { - return sprout::csub(arr, sprout::begin(arr), sprout::end(arr)); + return sprout::csub_window(arr, to_first); } // @@ -275,16 +226,6 @@ namespace sprout { } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type - sub_copy( - Container const& arr, - typename sprout::container_traits::difference_type first, - typename sprout::container_traits::difference_type last - ) - { - return sprout::sub_array(arr, first, last); - } - template - inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub_copy( Container const& arr, typename sprout::container_traits::const_iterator first @@ -296,22 +237,22 @@ namespace sprout { inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub_copy( Container const& arr, - typename sprout::container_traits::difference_type first + typename sprout::container_traits::difference_type to_first, + typename sprout::container_traits::difference_type to_last ) { - return sprout::sub_copy(arr, first, sprout::size(arr)); + return sprout::sub_window_copy(arr, to_first, to_last); } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type - ub_copy( - Container const& arr + sub_copy( + Container const& arr, + typename sprout::container_traits::difference_type to_first = 0 ) { - return sprout::sub_copy(arr, sprout::begin(arr), sprout::end(arr)); + return sprout::sub_window_copy(arr, to_first); } - // - // sub_copy - // + template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub_copy( @@ -324,20 +265,6 @@ namespace sprout { } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type - sub_copy( - Container const& arr, - typename sprout::container_traits::difference_type first, - typename sprout::container_traits::difference_type last - ) - { - return sprout::sub_array( - arr.get_array(), - sprout::next(sprout::begin(arr), first), - sprout::next(sprout::begin(arr), last) - ); - } - template - inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub_copy( Container const& arr, typename sprout::container_traits::const_iterator first @@ -349,18 +276,20 @@ namespace sprout { inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub_copy( Container const& arr, - typename sprout::container_traits::difference_type first + typename sprout::container_traits::difference_type to_first, + typename sprout::container_traits::difference_type to_last ) { - return sprout::sub_copy(arr, first, sprout::size(arr)); + return sprout::sub_window_copy(arr, to_first, to_last); } template inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type sub_copy( - Container const& arr + Container const& arr, + typename sprout::container_traits::difference_type to_first = 0 ) { - return sprout::sub_copy(arr, sprout::begin(arr), sprout::end(arr)); + return sprout::sub_window_copy(arr, to_first); } } // namespace sprout diff --git a/sprout/sub_array/sub_array.hpp b/sprout/sub_array/sub_array.hpp index 65a014d6..625c9e23 100644 --- a/sprout/sub_array/sub_array.hpp +++ b/sprout/sub_array/sub_array.hpp @@ -98,8 +98,8 @@ namespace sprout { } protected: holder_type array_; - impl_difference_type first_; - impl_difference_type last_; + impl_difference_type to_first_; + impl_difference_type to_last_; public: sub_array_impl() = default; protected: @@ -113,8 +113,8 @@ namespace sprout { typename std::enable_if::value>::type* = 0 ) : array_{to_holder(arr)[Indexes]...} - , first_(sprout::distance(sprout::cbegin(arr), first)) - , last_(sprout::distance(sprout::cbegin(arr), last)) + , to_first_(sprout::distance(sprout::cbegin(arr), first)) + , to_last_(sprout::distance(sprout::cbegin(arr), last)) {} template SPROUT_CONSTEXPR sub_array_impl( @@ -126,34 +126,34 @@ namespace sprout { typename std::enable_if::value>::type* = 0 ) : array_(to_holder(arr)) - , first_(sprout::distance(sprout::cbegin(arr), first)) - , last_(sprout::distance(sprout::cbegin(arr), last)) + , to_first_(sprout::distance(sprout::cbegin(arr), first)) + , to_last_(sprout::distance(sprout::cbegin(arr), last)) {} template SPROUT_CONSTEXPR sub_array_impl( ContainerTag, param_type arr, sprout::index_tuple, - impl_difference_type first, - impl_difference_type last, + impl_difference_type to_first, + impl_difference_type to_last, typename std::enable_if::value>::type* = 0 ) : array_{to_holder(arr)[Indexes]...} - , first_(first) - , last_(last) + , to_first_(to_first) + , to_last_(to_last) {} template SPROUT_CONSTEXPR sub_array_impl( ContainerTag, param_type arr, sprout::index_tuple, - impl_difference_type first, - impl_difference_type last, + impl_difference_type to_first, + impl_difference_type to_last, typename std::enable_if::value>::type* = 0 ) : array_(to_holder(arr)) - , first_(first) - , last_(last) + , to_first_(to_first) + , to_last_(to_last) {} }; } // namespace detail @@ -194,8 +194,8 @@ namespace sprout { typedef typename impl_type::array_tag array_tag; private: using impl_type::array_; - using impl_type::first_; - using impl_type::last_; + using impl_type::to_first_; + using impl_type::to_last_; public: // construct/copy/destroy: sub_array() = default; @@ -208,13 +208,13 @@ namespace sprout { last ) {} - SPROUT_CONSTEXPR sub_array(param_type arr, difference_type first, difference_type last) + SPROUT_CONSTEXPR sub_array(param_type arr, difference_type to_first, difference_type to_last) : impl_type( array_tag(), arr, sprout::index_range<0, enumerable_size>::make(), - first, - last + to_first, + to_last ) {} SPROUT_CONSTEXPR sub_array(sub_array const& other, const_iterator first, const_iterator last) @@ -226,13 +226,13 @@ 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 to_first, difference_type to_last) : impl_type( array_tag(), impl_type::template to_param(other.array_), sprout::index_range<0, enumerable_size>::make(), - first + other.first_, - last + other.first_ + other.to_first_ + to_first, + other.to_first_ + to_last ) {} @@ -244,89 +244,89 @@ namespace sprout { SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(other.array_, array_))) { sprout::swap(other.array_, array_); - sprout::swap(other.first_, first_); - sprout::swap(other.last_, last_); + sprout::swap(other.to_first_, to_first_); + sprout::swap(other.to_last_, to_last_); } // iterators: iterator begin() { - return sprout::next(sprout::begin(get_array()), first_); + return sprout::next(sprout::begin(get_array()), to_first_); } SPROUT_CONSTEXPR const_iterator begin() const { - return sprout::next(sprout::begin(get_array()), first_); + return sprout::next(sprout::begin(get_array()), to_first_); } iterator end() { - return sprout::next(sprout::begin(get_array()), last_); + return sprout::next(sprout::begin(get_array()), to_last_); } SPROUT_CONSTEXPR const_iterator end() const { - return sprout::next(sprout::begin(get_array()), last_); + return sprout::next(sprout::begin(get_array()), to_last_); } SPROUT_CONSTEXPR const_iterator cbegin() const { - return sprout::next(sprout::begin(get_array()), first_); + return sprout::next(sprout::begin(get_array()), to_first_); } SPROUT_CONSTEXPR const_iterator cend() const { - return sprout::next(sprout::begin(get_array()), last_); + return sprout::next(sprout::begin(get_array()), to_last_); } // capacity: SPROUT_CONSTEXPR size_type size() const { - return last_ - first_; + return to_last_ - to_first_; } SPROUT_CONSTEXPR size_type max_size() const { return size(); } SPROUT_CONSTEXPR bool empty() const { - return first_ == last_; + return to_first_ == to_last_; } // element access: reference operator[](size_type i) { - return *sprout::next(sprout::begin(get_array()), first_ + i); + return *sprout::next(sprout::begin(get_array()), to_first_ + i); } SPROUT_CONSTEXPR const_reference operator[](size_type i) const { - return *sprout::next(sprout::begin(get_array()), first_ + i); + return *sprout::next(sprout::begin(get_array()), to_first_ + i); } reference at(size_type i) { return i < size() - ? *sprout::next(sprout::begin(get_array()), first_ + i) - : (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_array()), first_ + i)) + ? *sprout::next(sprout::begin(get_array()), to_first_ + i) + : (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_array()), to_first_ + i)) ; } SPROUT_CONSTEXPR const_reference at(size_type i) const { return i < size() - ? *sprout::next(sprout::begin(get_array()), first_ + i) - : (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_array()), first_ + i)) + ? *sprout::next(sprout::begin(get_array()), to_first_ + i) + : (throw std::out_of_range("sub_array<>: index out of range"), *sprout::next(sprout::begin(get_array()), to_first_ + i)) ; } reference front() { - return *sprout::next(sprout::begin(get_array()), first_); + return *sprout::next(sprout::begin(get_array()), to_first_); } SPROUT_CONSTEXPR const_reference front() const { - return *sprout::next(sprout::begin(get_array()), first_); + return *sprout::next(sprout::begin(get_array()), to_first_); } reference back() { - return *sprout::next(sprout::begin(get_array()), last_ - 1); + return *sprout::next(sprout::begin(get_array()), to_last_ - 1); } SPROUT_CONSTEXPR const_reference back() const { - return *sprout::next(sprout::begin(get_array()), last_ - 1); + return *sprout::next(sprout::begin(get_array()), to_last_ - 1); } pointer data() { - return get_array().data() + first_; + return get_array().data() + to_first_; } SPROUT_CONSTEXPR const_pointer data() const { - return get_array().data() + first_; + return get_array().data() + to_first_; } // others: template sub_array& operator=(sub_array const& rhs) { array_ = rhs.array_; - first_ = rhs.first_; - last_ = rhs.last_; + to_first_ = rhs.to_first_; + to_last_ = rhs.to_last_; return *this; } template sub_array& operator=(sub_array&& rhs) { array_ = std::move(rhs.array_); - first_ = std::move(rhs.first_); - last_ = std::move(rhs.last_); + to_first_ = std::move(rhs.to_first_); + to_last_ = std::move(rhs.to_last_); return *this; } pointer c_array() { @@ -353,6 +353,12 @@ namespace sprout { SPROUT_CONSTEXPR const_param_type get_array() const { return impl_type::template to_const_param(array_); } + SPROUT_CONSTEXPR difference_type to_first() const { + return to_first_; + } + SPROUT_CONSTEXPR difference_type to_last() const { + return to_last_; + } }; template SPROUT_CONSTEXPR_OR_CONST typename sprout::sub_array::size_type sprout::sub_array::enumerable_size; diff --git a/sprout/sub_array/sub_offset.hpp b/sprout/sub_array/sub_offset.hpp new file mode 100644 index 00000000..4e6e341a --- /dev/null +++ b/sprout/sub_array/sub_offset.hpp @@ -0,0 +1,103 @@ +#ifndef SPROUT_SUB_ARRAY_SUB_OFFSET_HPP +#define SPROUT_SUB_ARRAY_SUB_OFFSET_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // sub_offset + // + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_offset( + Container& arr, + typename sprout::container_traits >::difference_type from_begin = 0, + typename sprout::container_traits >::difference_type from_end = 0 + ) + { + return sprout::sub_array(arr, from_begin, sprout::size(arr) + from_end); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_offset( + Container const& arr, + typename sprout::container_traits >::difference_type from_begin = 0, + typename sprout::container_traits >::difference_type from_end = 0 + ) + { + return sprout::sub_array(arr, from_begin, sprout::size(arr) + from_end); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, Container>::type + sub_offset( + Container const& arr, + typename sprout::container_traits::difference_type from_begin = 0, + typename sprout::container_traits::difference_type from_end = 0 + ) + { + return Container(arr, from_begin, sprout::size(arr) + from_end); + } + + // + // csub_offset + // + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + csub_offset( + Container const& arr, + typename sprout::container_traits >::difference_type from_begin = 0, + typename sprout::container_traits >::difference_type from_end = 0 + ) + { + return sprout::sub_offset(arr, from_begin, from_end); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + csub_offset( + Container const& arr, + typename sprout::container_traits::difference_type from_begin = 0, + typename sprout::container_traits::difference_type from_end = 0 + ) + { + return sprout::sub_array( + arr.get_array(), + arr.to_first() + from_begin, + arr.to_last() + from_end + ); + } + + // + // sub_offset_copy + // + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_offset_copy( + Container const& arr, + typename sprout::container_traits::difference_type from_begin = 0, + typename sprout::container_traits::difference_type from_end = 0 + ) + { + return sprout::sub_array(arr, from_begin, sprout::size(arr) + from_end); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_offset_copy( + Container const& arr, + typename sprout::container_traits::difference_type from_begin = 0, + typename sprout::container_traits::difference_type from_end = 0 + ) + { + return sprout::sub_array( + arr.get_array(), + arr.to_first() + from_begin, + arr.to_last() + from_end + ); + } +} // namespace sprout + +#endif // #ifndef SPROUT_SUB_ARRAY_SUB_OFFSET_HPP diff --git a/sprout/sub_array/sub_window.hpp b/sprout/sub_array/sub_window.hpp new file mode 100644 index 00000000..006659ad --- /dev/null +++ b/sprout/sub_array/sub_window.hpp @@ -0,0 +1,174 @@ +#ifndef SPROUT_SUB_ARRAY_SUB_WINDOW_HPP +#define SPROUT_SUB_ARRAY_SUB_WINDOW_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // sub_window + // + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_window( + Container& arr, + typename sprout::container_traits >::difference_type to_first, + typename sprout::container_traits >::difference_type to_last + ) + { + return sprout::sub_array(arr, to_first, to_last); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_window( + Container& arr, + typename sprout::container_traits >::difference_type to_first = 0 + ) + { + return sprout::sub_array(arr, to_first, sprout::size(arr)); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_window( + Container const& arr, + typename sprout::container_traits >::difference_type to_first, + typename sprout::container_traits >::difference_type to_last + ) + { + return sprout::sub_array(arr, to_first, to_last); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_window( + Container const& arr, + typename sprout::container_traits >::difference_type to_first = 0 + ) + { + return sprout::sub_array(arr, to_first, sprout::size(arr)); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, Container>::type + sub_window( + Container const& arr, + typename sprout::container_traits::difference_type to_first, + typename sprout::container_traits::difference_type to_last + ) + { + return Container(arr, to_first, to_last); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, Container>::type + sub_window( + Container const& arr, + typename sprout::container_traits::difference_type to_first = 0 + ) + { + return Container(arr, to_first, sprout::size(arr)); + } + + // + // csub_window + // + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + csub_window( + Container const& arr, + typename sprout::container_traits >::difference_type to_first, + typename sprout::container_traits >::difference_type to_last + ) + { + return sprout::sub_window(arr, to_first, to_last); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + csub_window( + Container const& arr, + typename sprout::container_traits >::difference_type to_first = 0 + ) + { + return sprout::sub_window(arr, to_first, sprout::size(arr)); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + csub_window( + Container const& arr, + typename sprout::container_traits::difference_type to_first, + typename sprout::container_traits::difference_type to_last + ) + { + return sprout::sub_array( + arr.get_array(), + arr.to_first() + to_first, + arr.to_first() + to_last + ); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + csub_window( + Container const& arr, + typename sprout::container_traits::difference_type to_first = 0 + ) + { + return sprout::sub_array( + arr.get_array(), + arr.to_first() + to_first, + arr.to_first() + sprout::size(arr) + ); + } + + // + // sub_window_copy + // + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_window_copy( + Container const& arr, + typename sprout::container_traits::difference_type to_first, + typename sprout::container_traits::difference_type to_last + ) + { + return sprout::sub_array(arr, to_first, to_last); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_window_copy( + Container const& arr, + typename sprout::container_traits::difference_type to_first = 0 + ) + { + return sprout::sub_array(arr, to_first, sprout::size(arr)); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_window_copy( + Container const& arr, + typename sprout::container_traits::difference_type to_first, + typename sprout::container_traits::difference_type to_last + ) + { + return sprout::sub_array( + arr.get_array(), + arr.to_first() + to_first, + arr.to_first() + to_last + ); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if::value, sprout::sub_array >::type + sub_window_copy( + Container const& arr, + typename sprout::container_traits::difference_type to_first = 0 + ) + { + return sprout::sub_array( + arr.get_array(), + arr.to_first() + to_first, + arr.to_first() + sprout::size(arr) + ); + } +} // namespace sprout + +#endif // #ifndef SPROUT_SUB_ARRAY_SUB_WINDOW_HPP