add sub_window, add sub_offset

This commit is contained in:
bolero-MURAKAMI 2013-02-26 16:14:04 +09:00
parent bf8c46b203
commit 899bf3fa77
72 changed files with 610 additions and 353 deletions

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/functional/equal_to.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/detail/algorithm/search_one.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/functional/equal_to.hpp>
#include <sprout/functional/bind2nd.hpp>
#include <sprout/algorithm/find_if.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -11,7 +11,7 @@
#include <sprout/sub_array/sub.hpp>
#include <sprout/detail/algorithm/count_n_if.hpp>
#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/detail/algorithm/set_overlap_count.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/detail/algorithm/set_overlap_count.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/detail/algorithm/set_overlap_count.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/detail/algorithm/set_overlap_count.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/detail/algorithm/overlap_count.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -12,7 +12,7 @@
#include <sprout/pit/pit.hpp>
#include <sprout/math/comparison.hpp>
#include <sprout/detail/container_complate.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fixed {

View file

@ -10,7 +10,7 @@
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/pit/pit.hpp>
#include <sprout/detail/container_complate.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fixed {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/functional/less.hpp>
#include <sprout/utility/pair/pair.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/algorithm/none_of.hpp>
#include <sprout/algorithm/find_if_not.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/algorithm/is_sorted_until.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/iterator/type_traits/common.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/algorithm/min.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/utility/pair/access.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/functional/equal_to.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/detail/algorithm/search_one.hpp>

View file

@ -7,7 +7,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/pit/pit.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/range/adaptor/size_enumed.hpp>
#include <sprout/range/algorithm/lower_bound.hpp>
#include <sprout/range/numeric/partial_sum.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/iterator/type_traits/common.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/algorithm/min.hpp>

View file

@ -11,7 +11,7 @@
#include <sprout/container/internal_begin_offset_backward.hpp>
#include <sprout/container/internal_end_offset_backward.hpp>
#include <sprout/iterator/remake_iterator.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/tpp/algorithm/all_of.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/algorithm/count.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/algorithm/count_if.hpp>

View file

@ -4,7 +4,7 @@
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/tuple/tuple/tuple.hpp>
#include <sprout/tuple/tuple/get.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT

View file

@ -4,7 +4,7 @@
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/iterator/type_traits/common.hpp>
#include <sprout/tuple/tuple/tuple.hpp>
#include <sprout/tuple/tuple/get.hpp>

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/next.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/utility/pair/pair.hpp>
#include <sprout/adl/not_found.hpp>

View file

@ -2,7 +2,7 @@
#define SPROUT_ITERATOR_TYPE_TRAITS_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/iterator/type_traits/common.hpp>
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_HPP

View file

@ -0,0 +1,10 @@
#ifndef SPROUT_ITERATOR_TYPE_TRAITS_CATEGORY_HPP
#define SPROUT_ITERATOR_TYPE_TRAITS_CATEGORY_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/is_iterator_category_of.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/iterator/type_traits/is_constant_distance_iterator.hpp>
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_CATEGORY_HPP

View file

@ -4,7 +4,7 @@
#include <iterator>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace detail {

View file

@ -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 <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
namespace sprout {
//
// is_constant_distance_iterator
//
template<typename MaybeIterator>
struct is_constant_distance_iterator
: public std::integral_constant<
bool,
sprout::is_random_access_iterator<MaybeIterator>::value && !std::is_pointer<MaybeIterator>::value
>
{};
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_CONSTANT_DISTANCE_ITERATOR_HPP

View file

@ -2,7 +2,6 @@
#define SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_HPP
#include <iterator>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/has_xxx.hpp>
@ -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<std::iterator_traits<MaybeIterator> >
{};
//
// is_iterator_category_of
//
template<typename MaybeCategory, typename Category>
struct is_iterator_category_of
: public std::is_convertible<MaybeCategory, Category>
{};
//
// is_input_iterator_category
//
template<typename MaybeCategory>
struct is_input_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::input_iterator_tag>
{};
//
// is_output_iterator_category
//
template<typename MaybeCategory>
struct is_output_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::output_iterator_tag>
{};
//
// is_forward_iterator_category
//
template<typename MaybeCategory>
struct is_forward_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::forward_iterator_tag>
{};
//
// is_bidirectional_iterator_category
//
template<typename MaybeCategory>
struct is_bidirectional_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::bidirectional_iterator_tag>
{};
//
// is_random_access_iterator_category
//
template<typename MaybeCategory>
struct is_random_access_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::random_access_iterator_tag>
{};
namespace detail {
template<typename MaybeIterator, typename Category, typename = void>
struct is_iterator_of_impl
: public std::false_type
{};
template<typename MaybeIterator, typename Category>
struct is_iterator_of_impl<
MaybeIterator, Category,
typename std::enable_if<sprout::is_iterator<MaybeIterator>::value>::type
>
: public sprout::is_iterator_category_of<typename std::iterator_traits<MaybeIterator>::iterator_category, Category>
{};
} // namespace detail
//
// is_iterator_of
//
template<typename MaybeIterator, typename Category>
struct is_iterator_of
: public sprout::detail::is_iterator_of_impl<MaybeIterator, Category>
{};
//
// is_input_iterator
//
template<typename MaybeIterator>
struct is_input_iterator
: public sprout::is_iterator_of<MaybeIterator, std::input_iterator_tag>
{};
//
// is_output_iterator
//
template<typename MaybeIterator>
struct is_output_iterator
: public sprout::is_iterator_of<MaybeIterator, std::output_iterator_tag>
{};
//
// is_forward_iterator
//
template<typename MaybeIterator>
struct is_forward_iterator
: public sprout::is_iterator_of<MaybeIterator, std::forward_iterator_tag>
{};
//
// is_bidirectional_iterator
//
template<typename MaybeIterator>
struct is_bidirectional_iterator
: public sprout::is_iterator_of<MaybeIterator, std::bidirectional_iterator_tag>
{};
//
// is_random_access_iterator
//
template<typename MaybeIterator>
struct is_random_access_iterator
: public sprout::is_iterator_of<MaybeIterator, std::random_access_iterator_tag>
{};
//
// is_constant_distance_iterator
//
template<typename MaybeIterator>
struct is_constant_distance_iterator
: public std::integral_constant<
bool,
sprout::is_random_access_iterator<MaybeIterator>::value && !std::is_pointer<MaybeIterator>::value
>
{};
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_HPP

View file

@ -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 <iterator>
#include <type_traits>
#include <sprout/config.hpp>
namespace sprout {
//
// is_iterator_category_of
//
template<typename MaybeCategory, typename Category>
struct is_iterator_category_of
: public std::is_convertible<MaybeCategory, Category>
{};
//
// is_input_iterator_category
//
template<typename MaybeCategory>
struct is_input_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::input_iterator_tag>
{};
//
// is_output_iterator_category
//
template<typename MaybeCategory>
struct is_output_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::output_iterator_tag>
{};
//
// is_forward_iterator_category
//
template<typename MaybeCategory>
struct is_forward_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::forward_iterator_tag>
{};
//
// is_bidirectional_iterator_category
//
template<typename MaybeCategory>
struct is_bidirectional_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::bidirectional_iterator_tag>
{};
//
// is_random_access_iterator_category
//
template<typename MaybeCategory>
struct is_random_access_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::random_access_iterator_tag>
{};
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_CATEGORY_OF_HPP

View file

@ -0,0 +1,70 @@
#ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_OF_HPP
#define SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_OF_HPP
#include <iterator>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/is_iterator_category_of.hpp>
namespace sprout {
namespace detail {
template<typename MaybeIterator, typename Category, typename = void>
struct is_iterator_of_impl
: public std::false_type
{};
template<typename MaybeIterator, typename Category>
struct is_iterator_of_impl<
MaybeIterator, Category,
typename std::enable_if<sprout::is_iterator<MaybeIterator>::value>::type
>
: public sprout::is_iterator_category_of<typename std::iterator_traits<MaybeIterator>::iterator_category, Category>
{};
} // namespace detail
//
// is_iterator_of
//
template<typename MaybeIterator, typename Category>
struct is_iterator_of
: public sprout::detail::is_iterator_of_impl<MaybeIterator, Category>
{};
//
// is_input_iterator
//
template<typename MaybeIterator>
struct is_input_iterator
: public sprout::is_iterator_of<MaybeIterator, std::input_iterator_tag>
{};
//
// is_output_iterator
//
template<typename MaybeIterator>
struct is_output_iterator
: public sprout::is_iterator_of<MaybeIterator, std::output_iterator_tag>
{};
//
// is_forward_iterator
//
template<typename MaybeIterator>
struct is_forward_iterator
: public sprout::is_iterator_of<MaybeIterator, std::forward_iterator_tag>
{};
//
// is_bidirectional_iterator
//
template<typename MaybeIterator>
struct is_bidirectional_iterator
: public sprout::is_iterator_of<MaybeIterator, std::bidirectional_iterator_tag>
{};
//
// is_random_access_iterator
//
template<typename MaybeIterator>
struct is_random_access_iterator
: public sprout::is_iterator_of<MaybeIterator, std::random_access_iterator_tag>
{};
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_OF_HPP

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/functional/plus.hpp>
#include <sprout/utility/pair/pair.hpp>

View file

@ -10,7 +10,7 @@
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/pit/pit.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -10,7 +10,7 @@
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/pit/pit.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -9,7 +9,7 @@
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
namespace sprout {
namespace fit {

View file

@ -5,7 +5,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator.hpp>
#include <sprout/iterator/type_traits/category.hpp>
#include <sprout/iterator/type_traits/common.hpp>
#include <sprout/functional/plus.hpp>
#include <sprout/functional/multiplies.hpp>

View file

@ -88,18 +88,18 @@ namespace sprout {
return sprout::adaptors::detail::adapted_range_default<
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>(
sprout::next(
sprout::begin(sprout::lvalue_forward<Range>(lhs)),
NS_SSCRISK_CEL_OR_SPROUT::min<difference_type>(rhs.from_begin(), sprout::size(sprout::lvalue_forward<Range>(lhs)))
),
sprout::next(
sprout::end(sprout::lvalue_forward<Range>(lhs)),
NS_SSCRISK_CEL_OR_SPROUT::max<difference_type>(
rhs.from_end(),
NS_SSCRISK_CEL_OR_SPROUT::min<difference_type>(rhs.from_begin() - sprout::size(sprout::lvalue_forward<Range>(lhs)), 0)
)
sprout::next(
sprout::begin(sprout::lvalue_forward<Range>(lhs)),
NS_SSCRISK_CEL_OR_SPROUT::min<difference_type>(rhs.from_begin(), sprout::size(sprout::lvalue_forward<Range>(lhs)))
),
sprout::next(
sprout::end(sprout::lvalue_forward<Range>(lhs)),
NS_SSCRISK_CEL_OR_SPROUT::max<difference_type>(
rhs.from_end(),
NS_SSCRISK_CEL_OR_SPROUT::min<difference_type>(rhs.from_begin() - sprout::size(sprout::lvalue_forward<Range>(lhs)), 0)
)
);
)
);
}
template<typename Range, typename Difference>
inline SPROUT_CONSTEXPR sprout::adaptors::detail::adapted_range_default<

View file

@ -8,6 +8,8 @@
#include <sprout/sub_array/tuple.hpp>
#include <sprout/sub_array/container.hpp>
#include <sprout/sub_array/sub.hpp>
#include <sprout/sub_array/sub_window.hpp>
#include <sprout/sub_array/sub_offset.hpp>
#include <sprout/sub_array/type_traits.hpp>
#endif // #ifndef SPROUT_SUB_ARRAY_HPP

View file

@ -7,6 +7,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/type_traits.hpp>
#include <sprout/sub_array/sub_window.hpp>
namespace sprout {
//
@ -24,16 +25,6 @@ namespace sprout {
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
sub(
Container& arr,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type first,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type last
)
{
return sprout::sub_array<Container&>(arr, first, last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
sub(
Container& arr,
typename sprout::container_traits<sprout::sub_array<Container&> >::const_iterator first
@ -45,22 +36,22 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
sub(
Container& arr,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type first
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_first,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_last
)
{
return sprout::sub(arr, first, sprout::size(arr));
return sprout::sub_window(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
sub(
Container& arr
Container& arr,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_first = 0
)
{
return sprout::sub(arr, sprout::begin(arr), sprout::end(arr));
return sprout::sub_window(arr, to_first);
}
//
// sub
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
sub(
@ -73,16 +64,6 @@ namespace sprout {
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
sub(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type first,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type last
)
{
return sprout::sub_array<Container const&>(arr, first, last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
sub(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::const_iterator first
@ -94,22 +75,22 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
sub(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type first
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_last
)
{
return sprout::sub(arr, first, sprout::size(arr));
return sprout::sub_window(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
sub(
Container const& arr
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first = 0
)
{
return sprout::sub(arr, sprout::begin(arr), sprout::end(arr));
return sprout::sub_window(arr, to_first);
}
//
// sub
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
sub(
@ -122,16 +103,6 @@ namespace sprout {
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
sub(
Container const& arr,
typename sprout::container_traits<Container>::difference_type first,
typename sprout::container_traits<Container>::difference_type last
)
{
return Container(arr, first, last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
sub(
Container const& arr,
typename sprout::container_traits<Container>::const_iterator first
@ -143,18 +114,20 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
sub(
Container const& arr,
typename sprout::container_traits<Container>::difference_type first
typename sprout::container_traits<Container>::difference_type to_first,
typename sprout::container_traits<Container>::difference_type to_last
)
{
return sprout::sub(arr, first, sprout::size(arr));
return sprout::sub_window(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
sub(
Container const& arr
Container const& arr,
typename sprout::container_traits<Container>::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<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
csub(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type first,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type last
)
{
return sprout::sub_array<Container const&>(arr, first, last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
csub(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::const_iterator first
@ -193,22 +156,22 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
csub(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type first
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_last
)
{
return sprout::csub(arr, first, sprout::size(arr));
return sprout::csub_window(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
csub(
Container const& arr
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first = 0
)
{
return sprout::csub(arr, sprout::begin(arr), sprout::end(arr));
return sprout::csub_window(arr, to_first);
}
//
// csub
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
csub(
@ -221,20 +184,6 @@ namespace sprout {
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
csub(
Container const& arr,
typename sprout::container_traits<Container>::difference_type first,
typename sprout::container_traits<Container>::difference_type last
)
{
return sprout::sub_array<typename Container::internal_type const&>(
arr.get_array(),
sprout::next(sprout::begin(arr), first),
sprout::next(sprout::begin(arr), last)
);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
csub(
Container const& arr,
typename sprout::container_traits<Container>::const_iterator first
@ -246,18 +195,20 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
csub(
Container const& arr,
typename sprout::container_traits<Container>::difference_type first
typename sprout::container_traits<Container>::difference_type to_first,
typename sprout::container_traits<Container>::difference_type to_last
)
{
return sprout::csub(arr, first, sprout::size(arr));
return sprout::csub_window(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
csub(
Container const& arr
Container const& arr,
typename sprout::container_traits<Container>::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<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
sub_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type first,
typename sprout::container_traits<Container>::difference_type last
)
{
return sprout::sub_array<Container>(arr, first, last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
sub_copy(
Container const& arr,
typename sprout::container_traits<Container>::const_iterator first
@ -296,22 +237,22 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
sub_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type first
typename sprout::container_traits<Container>::difference_type to_first,
typename sprout::container_traits<Container>::difference_type to_last
)
{
return sprout::sub_copy(arr, first, sprout::size(arr));
return sprout::sub_window_copy(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
ub_copy(
Container const& arr
sub_copy(
Container const& arr,
typename sprout::container_traits<Container>::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<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
sub_copy(
@ -324,20 +265,6 @@ namespace sprout {
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
sub_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type first,
typename sprout::container_traits<Container>::difference_type last
)
{
return sprout::sub_array<typename Container::internal_type>(
arr.get_array(),
sprout::next(sprout::begin(arr), first),
sprout::next(sprout::begin(arr), last)
);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
sub_copy(
Container const& arr,
typename sprout::container_traits<Container>::const_iterator first
@ -349,18 +276,20 @@ namespace sprout {
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
sub_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type first
typename sprout::container_traits<Container>::difference_type to_first,
typename sprout::container_traits<Container>::difference_type to_last
)
{
return sprout::sub_copy(arr, first, sprout::size(arr));
return sprout::sub_window_copy(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
sub_copy(
Container const& arr
Container const& arr,
typename sprout::container_traits<Container>::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

View file

@ -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<std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0
)
: array_{to_holder<Container>(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<typename ContainerTag, sprout::index_t... Indexes>
SPROUT_CONSTEXPR sub_array_impl(
@ -126,34 +126,34 @@ namespace sprout {
typename std::enable_if<!std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0
)
: array_(to_holder<Container>(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<typename ContainerTag, sprout::index_t... Indexes>
SPROUT_CONSTEXPR sub_array_impl(
ContainerTag,
param_type arr,
sprout::index_tuple<Indexes...>,
impl_difference_type first,
impl_difference_type last,
impl_difference_type to_first,
impl_difference_type to_last,
typename std::enable_if<std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0
)
: array_{to_holder<Container>(arr)[Indexes]...}
, first_(first)
, last_(last)
, to_first_(to_first)
, to_last_(to_last)
{}
template<typename ContainerTag, sprout::index_t... Indexes>
SPROUT_CONSTEXPR sub_array_impl(
ContainerTag,
param_type arr,
sprout::index_tuple<Indexes...>,
impl_difference_type first,
impl_difference_type last,
impl_difference_type to_first,
impl_difference_type to_last,
typename std::enable_if<!std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0
)
: array_(to_holder<Container>(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<Container>(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<typename Container2>
sub_array& operator=(sub_array<Container2> const& rhs) {
array_ = rhs.array_;
first_ = rhs.first_;
last_ = rhs.last_;
to_first_ = rhs.to_first_;
to_last_ = rhs.to_last_;
return *this;
}
template<typename Container2>
sub_array& operator=(sub_array<Container2>&& 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<Container>(array_);
}
SPROUT_CONSTEXPR difference_type to_first() const {
return to_first_;
}
SPROUT_CONSTEXPR difference_type to_last() const {
return to_last_;
}
};
template<typename Container>
SPROUT_CONSTEXPR_OR_CONST typename sprout::sub_array<Container>::size_type sprout::sub_array<Container>::enumerable_size;

View file

@ -0,0 +1,103 @@
#ifndef SPROUT_SUB_ARRAY_SUB_OFFSET_HPP
#define SPROUT_SUB_ARRAY_SUB_OFFSET_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/type_traits.hpp>
namespace sprout {
//
// sub_offset
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
sub_offset(
Container& arr,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type from_begin = 0,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type from_end = 0
)
{
return sprout::sub_array<Container&>(arr, from_begin, sprout::size(arr) + from_end);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
sub_offset(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type from_begin = 0,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type from_end = 0
)
{
return sprout::sub_array<Container const&>(arr, from_begin, sprout::size(arr) + from_end);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
sub_offset(
Container const& arr,
typename sprout::container_traits<Container>::difference_type from_begin = 0,
typename sprout::container_traits<Container>::difference_type from_end = 0
)
{
return Container(arr, from_begin, sprout::size(arr) + from_end);
}
//
// csub_offset
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
csub_offset(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type from_begin = 0,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type from_end = 0
)
{
return sprout::sub_offset(arr, from_begin, from_end);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
csub_offset(
Container const& arr,
typename sprout::container_traits<Container>::difference_type from_begin = 0,
typename sprout::container_traits<Container>::difference_type from_end = 0
)
{
return sprout::sub_array<typename Container::internal_type const&>(
arr.get_array(),
arr.to_first() + from_begin,
arr.to_last() + from_end
);
}
//
// sub_offset_copy
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
sub_offset_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type from_begin = 0,
typename sprout::container_traits<Container>::difference_type from_end = 0
)
{
return sprout::sub_array<Container>(arr, from_begin, sprout::size(arr) + from_end);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
sub_offset_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type from_begin = 0,
typename sprout::container_traits<Container>::difference_type from_end = 0
)
{
return sprout::sub_array<typename Container::internal_type>(
arr.get_array(),
arr.to_first() + from_begin,
arr.to_last() + from_end
);
}
} // namespace sprout
#endif // #ifndef SPROUT_SUB_ARRAY_SUB_OFFSET_HPP

View file

@ -0,0 +1,174 @@
#ifndef SPROUT_SUB_ARRAY_SUB_WINDOW_HPP
#define SPROUT_SUB_ARRAY_SUB_WINDOW_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/sub_array/sub_array.hpp>
#include <sprout/sub_array/type_traits.hpp>
namespace sprout {
//
// sub_window
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
sub_window(
Container& arr,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_first,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_last
)
{
return sprout::sub_array<Container&>(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
sub_window(
Container& arr,
typename sprout::container_traits<sprout::sub_array<Container&> >::difference_type to_first = 0
)
{
return sprout::sub_array<Container&>(arr, to_first, sprout::size(arr));
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
sub_window(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_last
)
{
return sprout::sub_array<Container const&>(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
sub_window(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first = 0
)
{
return sprout::sub_array<Container const&>(arr, to_first, sprout::size(arr));
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
sub_window(
Container const& arr,
typename sprout::container_traits<Container>::difference_type to_first,
typename sprout::container_traits<Container>::difference_type to_last
)
{
return Container(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type
sub_window(
Container const& arr,
typename sprout::container_traits<Container>::difference_type to_first = 0
)
{
return Container(arr, to_first, sprout::size(arr));
}
//
// csub_window
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
csub_window(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_last
)
{
return sprout::sub_window(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
csub_window(
Container const& arr,
typename sprout::container_traits<sprout::sub_array<Container const&> >::difference_type to_first = 0
)
{
return sprout::sub_window(arr, to_first, sprout::size(arr));
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
csub_window(
Container const& arr,
typename sprout::container_traits<Container>::difference_type to_first,
typename sprout::container_traits<Container>::difference_type to_last
)
{
return sprout::sub_array<typename Container::internal_type const&>(
arr.get_array(),
arr.to_first() + to_first,
arr.to_first() + to_last
);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type const&> >::type
csub_window(
Container const& arr,
typename sprout::container_traits<Container>::difference_type to_first = 0
)
{
return sprout::sub_array<typename Container::internal_type const&>(
arr.get_array(),
arr.to_first() + to_first,
arr.to_first() + sprout::size(arr)
);
}
//
// sub_window_copy
//
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
sub_window_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type to_first,
typename sprout::container_traits<Container>::difference_type to_last
)
{
return sprout::sub_array<Container>(arr, to_first, to_last);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
sub_window_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type to_first = 0
)
{
return sprout::sub_array<Container>(arr, to_first, sprout::size(arr));
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
sub_window_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type to_first,
typename sprout::container_traits<Container>::difference_type to_last
)
{
return sprout::sub_array<typename Container::internal_type>(
arr.get_array(),
arr.to_first() + to_first,
arr.to_first() + to_last
);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::internal_type> >::type
sub_window_copy(
Container const& arr,
typename sprout::container_traits<Container>::difference_type to_first = 0
)
{
return sprout::sub_array<typename Container::internal_type>(
arr.get_array(),
arr.to_first() + to_first,
arr.to_first() + sprout::size(arr)
);
}
} // namespace sprout
#endif // #ifndef SPROUT_SUB_ARRAY_SUB_WINDOW_HPP