mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
fix sprout::size, sprout::empty implementations
This commit is contained in:
parent
2b28ddef6f
commit
3d01aac239
20 changed files with 431 additions and 47 deletions
|
@ -8,6 +8,7 @@
|
||||||
#ifndef SPROUT_ALGORITHM_FIT_PARTITION_COPY_HPP
|
#ifndef SPROUT_ALGORITHM_FIT_PARTITION_COPY_HPP
|
||||||
#define SPROUT_ALGORITHM_FIT_PARTITION_COPY_HPP
|
#define SPROUT_ALGORITHM_FIT_PARTITION_COPY_HPP
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/iterator/distance.hpp>
|
#include <sprout/iterator/distance.hpp>
|
||||||
#include <sprout/container/traits.hpp>
|
#include <sprout/container/traits.hpp>
|
||||||
|
@ -30,11 +31,12 @@ namespace sprout {
|
||||||
typename sprout::container_traits<Result>::difference_type offset
|
typename sprout::container_traits<Result>::difference_type offset
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
typedef typename std::iterator_traits<InputIterator>::difference_type diff_type;
|
||||||
return sprout::sub_copy(
|
return sprout::sub_copy(
|
||||||
sprout::get_internal(sprout::fixed::partition_copy(first, last, result, pred)),
|
sprout::get_internal(sprout::fixed::partition_copy(first, last, result, pred)),
|
||||||
offset,
|
offset,
|
||||||
offset + sprout::fit_size(
|
offset + sprout::fit_size(
|
||||||
result, sprout::detail::count_n_if(first, NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)), pred)
|
result, sprout::detail::count_n_if(first, NS_SSCRISK_CEL_OR_SPROUT::min<diff_type>(sprout::distance(first, last), sprout::size(result)), pred)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/workaround/std/cstddef.hpp>
|
#include <sprout/workaround/std/cstddef.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#include <sprout/container/container_traits.hpp>
|
#include <sprout/container/container_traits.hpp>
|
||||||
#include <sprout/container/container_range_traits.hpp>
|
|
||||||
#include <sprout/adl/not_found.hpp>
|
#include <sprout/adl/not_found.hpp>
|
||||||
|
|
||||||
namespace sprout_adl {
|
namespace sprout_adl {
|
||||||
|
@ -81,4 +81,6 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
#include <sprout/container/container_range_traits.hpp>
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CONTAINER_BEGIN_HPP
|
#endif // #ifndef SPROUT_CONTAINER_BEGIN_HPP
|
||||||
|
|
16
sprout/container/construct_functions.hpp
Normal file
16
sprout/container/construct_functions.hpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||||
|
https://github.com/bolero-MURAKAMI/Sprout
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
=============================================================================*/
|
||||||
|
#ifndef SPROUT_CONTAINER_CONSTRUCT_FUNCTIONS_HPP
|
||||||
|
#define SPROUT_CONTAINER_CONSTRUCT_FUNCTIONS_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/deep_copy.hpp>
|
||||||
|
#include <sprout/container/make.hpp>
|
||||||
|
#include <sprout/container/remake.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_CONTAINER_CONSTRUCT_FUNCTIONS_HPP
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#include <sprout/container/container_traits.hpp>
|
#include <sprout/container/container_traits.hpp>
|
||||||
#include <sprout/container/internal_begin.hpp>
|
#include <sprout/container/internal_begin.hpp>
|
||||||
#include <sprout/container/internal_end.hpp>
|
#include <sprout/container/internal_end.hpp>
|
||||||
|
@ -26,9 +27,6 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// container_construct_traits
|
// container_construct_traits
|
||||||
//
|
//
|
||||||
template<typename Container>
|
|
||||||
struct container_construct_traits;
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename Container, typename... Args>
|
template<typename Container, typename... Args>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#define SPROUT_CONTAINER_CONTAINER_FITNESS_TRAITS_HPP
|
#define SPROUT_CONTAINER_CONTAINER_FITNESS_TRAITS_HPP
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#include <sprout/container/container_traits.hpp>
|
#include <sprout/container/container_traits.hpp>
|
||||||
#include <sprout/container/size.hpp>
|
#include <sprout/container/size.hpp>
|
||||||
#include <sprout/utility/forward.hpp>
|
#include <sprout/utility/forward.hpp>
|
||||||
|
@ -23,7 +24,7 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
template<typename Cont>
|
template<typename Cont>
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type
|
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type
|
||||||
fit_size(Cont&& cont, typename sprout::container_traits<Container>::difference_type size) {
|
fit_size(Cont&& cont, typename sprout::container_traits<Container>::size_type size) {
|
||||||
return NS_SSCRISK_CEL_OR_SPROUT::min(size, sprout::size(SPROUT_FORWARD(Cont, cont)));
|
return NS_SSCRISK_CEL_OR_SPROUT::min(size, sprout::size(SPROUT_FORWARD(Cont, cont)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,17 +8,126 @@
|
||||||
#ifndef SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
#ifndef SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
||||||
#define SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
#define SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <utility>
|
||||||
|
#include <type_traits>
|
||||||
#include <sprout/workaround/std/cstddef.hpp>
|
#include <sprout/workaround/std/cstddef.hpp>
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/type_traits/identity.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#include <sprout/container/container_traits.hpp>
|
#include <sprout/container/container_traits.hpp>
|
||||||
|
#include <sprout/container/range_functions_fwd.hpp>
|
||||||
|
#include <sprout/container/begin.hpp>
|
||||||
|
#include <sprout/container/end.hpp>
|
||||||
|
#include <sprout/container/size.hpp>
|
||||||
|
#include <sprout/iterator/operation.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
//
|
//
|
||||||
// container_range_traits
|
// container_range_traits
|
||||||
//
|
//
|
||||||
|
namespace detail {
|
||||||
|
template<typename T>
|
||||||
|
struct has_mem_size_test {
|
||||||
|
public:
|
||||||
|
template<
|
||||||
|
typename U = T,
|
||||||
|
typename = typename sprout::identity<decltype(std::declval<U>().size())>::type
|
||||||
|
>
|
||||||
|
static sprout::true_type test(int);
|
||||||
|
static sprout::false_type test(...);
|
||||||
|
};
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout::detail::has_mem_size_test<T>::test(0))>::type>
|
||||||
|
struct has_mem_size
|
||||||
|
: public Base_
|
||||||
|
{};
|
||||||
|
#else
|
||||||
|
template<typename T>
|
||||||
|
struct has_mem_size
|
||||||
|
: public sprout::identity<decltype(sprout::detail::has_mem_size_test<T>::test(0))>::type
|
||||||
|
{};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<typename Container, typename = void>
|
||||||
|
struct container_range_traits_range_size_impl;
|
||||||
|
template<typename Container>
|
||||||
|
struct container_range_traits_range_size_impl<
|
||||||
|
Container,
|
||||||
|
typename std::enable_if<sprout::detail::has_mem_size<Container>::value>::type
|
||||||
|
> {
|
||||||
|
public:
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||||
|
range_size(Container const& cont) {
|
||||||
|
return cont.size();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename Container>
|
||||||
|
struct container_range_traits_range_size_impl<
|
||||||
|
Container,
|
||||||
|
typename std::enable_if<!sprout::detail::has_mem_size<Container>::value>::type
|
||||||
|
> {
|
||||||
|
public:
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::size_type
|
||||||
|
range_size(Container const& cont) {
|
||||||
|
return sprout::distance(sprout::begin(cont), sprout::end(cont));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct has_mem_empty_test {
|
||||||
|
public:
|
||||||
|
template<
|
||||||
|
typename U = T,
|
||||||
|
typename = typename sprout::identity<decltype(std::declval<U>().empty())>::type
|
||||||
|
>
|
||||||
|
static sprout::true_type test(int);
|
||||||
|
static sprout::false_type test(...);
|
||||||
|
};
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout::detail::has_mem_empty_test<T>::test(0))>::type>
|
||||||
|
struct has_mem_empty
|
||||||
|
: public Base_
|
||||||
|
{};
|
||||||
|
#else
|
||||||
|
template<typename T>
|
||||||
|
struct has_mem_empty
|
||||||
|
: public sprout::identity<decltype(sprout::detail::has_mem_empty_test<T>::test(0))>::type
|
||||||
|
{};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<typename Container, typename = void>
|
||||||
|
struct container_range_traits_range_empty_impl;
|
||||||
|
template<typename Container>
|
||||||
|
struct container_range_traits_range_empty_impl<
|
||||||
|
Container,
|
||||||
|
typename std::enable_if<sprout::detail::has_mem_empty<Container>::value>::type
|
||||||
|
> {
|
||||||
|
public:
|
||||||
|
static SPROUT_CONSTEXPR bool
|
||||||
|
range_empty(Container const& cont) {
|
||||||
|
return cont.empty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename Container>
|
||||||
|
struct container_range_traits_range_empty_impl<
|
||||||
|
Container,
|
||||||
|
typename std::enable_if<!sprout::detail::has_mem_empty<Container>::value>::type
|
||||||
|
> {
|
||||||
|
public:
|
||||||
|
static SPROUT_CONSTEXPR bool
|
||||||
|
range_empty(Container const& cont) {
|
||||||
|
return sprout::size(cont) == 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
struct container_range_traits {
|
struct container_range_traits
|
||||||
|
: public sprout::detail::container_range_traits_range_size_impl<Container>
|
||||||
|
, public sprout::detail::container_range_traits_range_empty_impl<Container>
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
// iterators:
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||||
range_begin(Container& cont) {
|
range_begin(Container& cont) {
|
||||||
return cont.begin();
|
return cont.begin();
|
||||||
|
@ -27,7 +136,6 @@ namespace sprout {
|
||||||
range_begin(Container const& cont) {
|
range_begin(Container const& cont) {
|
||||||
return cont.begin();
|
return cont.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||||
range_end(Container& cont) {
|
range_end(Container& cont) {
|
||||||
return cont.end();
|
return cont.end();
|
||||||
|
@ -40,20 +148,30 @@ namespace sprout {
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
struct container_range_traits<Container const> {
|
struct container_range_traits<Container const> {
|
||||||
public:
|
public:
|
||||||
|
// iterators:
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||||
range_begin(Container const& cont) {
|
range_begin(Container const& cont) {
|
||||||
return sprout::container_range_traits<Container>::range_begin(cont);
|
return sprout::container_range_traits<Container>::range_begin(cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||||
range_end(Container const& cont) {
|
range_end(Container const& cont) {
|
||||||
return sprout::container_range_traits<Container>::range_end(cont);
|
return sprout::container_range_traits<Container>::range_end(cont);
|
||||||
}
|
}
|
||||||
|
// capacity:
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||||
|
range_size(Container const& cont) {
|
||||||
|
return sprout::container_range_traits<Container>::range_size(cont);
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR bool
|
||||||
|
range_empty(Container const& cont) {
|
||||||
|
return sprout::container_range_traits<Container>::range_empty(cont);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
struct container_range_traits<T[N]> {
|
struct container_range_traits<T[N]> {
|
||||||
public:
|
public:
|
||||||
|
// iterators:
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
static SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||||
range_begin(T (& arr)[N]) {
|
range_begin(T (& arr)[N]) {
|
||||||
typedef typename sprout::container_traits<T[N]>::iterator type;
|
typedef typename sprout::container_traits<T[N]>::iterator type;
|
||||||
|
@ -64,7 +182,6 @@ namespace sprout {
|
||||||
typedef typename sprout::container_traits<T const[N]>::iterator type;
|
typedef typename sprout::container_traits<T const[N]>::iterator type;
|
||||||
return type(arr);
|
return type(arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
static SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||||
range_end(T (& arr)[N]) {
|
range_end(T (& arr)[N]) {
|
||||||
typedef typename sprout::container_traits<T[N]>::iterator type;
|
typedef typename sprout::container_traits<T[N]>::iterator type;
|
||||||
|
@ -75,19 +192,37 @@ namespace sprout {
|
||||||
typedef typename sprout::container_traits<T const[N]>::iterator type;
|
typedef typename sprout::container_traits<T const[N]>::iterator type;
|
||||||
return type(arr) + N;
|
return type(arr) + N;
|
||||||
}
|
}
|
||||||
|
// capacity:
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::size_type
|
||||||
|
range_size(T const (&)[N]) {
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR bool
|
||||||
|
range_empty(T const (&)[N]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
struct container_range_traits<T const[N]> {
|
struct container_range_traits<T const[N]> {
|
||||||
public:
|
public:
|
||||||
|
// iterators:
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||||
range_begin(T const (& arr)[N]) {
|
range_begin(T const (& arr)[N]) {
|
||||||
return sprout::container_range_traits<T[N]>::range_begin(arr);
|
return sprout::container_range_traits<T[N]>::range_begin(arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||||
range_end(T const (& arr)[N]) {
|
range_end(T const (& arr)[N]) {
|
||||||
return sprout::container_range_traits<T[N]>::range_end(arr);
|
return sprout::container_range_traits<T[N]>::range_end(arr);
|
||||||
}
|
}
|
||||||
|
// capacity:
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::size_type
|
||||||
|
range_size(T const (& arr)[N]) {
|
||||||
|
return sprout::container_range_traits<T[N]>::range_size(arr);
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR bool
|
||||||
|
range_empty(T const (& arr)[N]) {
|
||||||
|
return sprout::container_range_traits<T[N]>::range_empty(arr);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
|
|
@ -17,15 +17,13 @@
|
||||||
#include <sprout/type_traits/has_xxx.hpp>
|
#include <sprout/type_traits/has_xxx.hpp>
|
||||||
#include <sprout/type_traits/inherit_if_xxx.hpp>
|
#include <sprout/type_traits/inherit_if_xxx.hpp>
|
||||||
#include <sprout/container/detail/array_like.hpp>
|
#include <sprout/container/detail/array_like.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#if SPROUT_USE_PTR_INDEX_ITERATOR_IMPLEMENTATION
|
#if SPROUT_USE_PTR_INDEX_ITERATOR_IMPLEMENTATION
|
||||||
# include <sprout/iterator/ptr_index_iterator.hpp>
|
# include <sprout/iterator/ptr_index_iterator.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <sprout/workaround/base_class_construct.hpp>
|
#include <sprout/workaround/base_class_construct.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
template<typename Container>
|
|
||||||
struct container_traits;
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
//
|
//
|
||||||
// has_value_type
|
// has_value_type
|
||||||
|
@ -574,7 +572,7 @@ namespace sprout {
|
||||||
0
|
0
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
} // namespace sprout
|
} // namespace detail
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
|
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/workaround/std/cstddef.hpp>
|
#include <sprout/workaround/std/cstddef.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#include <sprout/container/container_traits.hpp>
|
#include <sprout/container/container_traits.hpp>
|
||||||
#include <sprout/container/detail/array_like.hpp>
|
#include <sprout/container/detail/array_like.hpp>
|
||||||
|
|
||||||
|
@ -18,9 +19,6 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// container_transform_traits
|
// container_transform_traits
|
||||||
//
|
//
|
||||||
template<typename Container>
|
|
||||||
struct container_transform_traits;
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename Container, typename sprout::container_traits<Container>::size_type Size>
|
template<typename Container, typename sprout::container_traits<Container>::size_type Size>
|
||||||
struct default_array_rebind_size;
|
struct default_array_rebind_size;
|
||||||
|
|
|
@ -9,18 +9,48 @@
|
||||||
#define SPROUT_CONTAINER_EMPTY_HPP
|
#define SPROUT_CONTAINER_EMPTY_HPP
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/container/begin.hpp>
|
#include <sprout/workaround/std/cstddef.hpp>
|
||||||
#include <sprout/container/end.hpp>
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
|
#include <sprout/container/container_traits.hpp>
|
||||||
|
#include <sprout/adl/not_found.hpp>
|
||||||
|
|
||||||
|
namespace sprout_adl {
|
||||||
|
sprout::not_found_via_adl range_empty(...);
|
||||||
|
} // namespace sprout_adl
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
|
namespace container_detail {
|
||||||
|
template<typename Container>
|
||||||
|
inline SPROUT_CONSTEXPR bool
|
||||||
|
range_empty(Container const& cont) {
|
||||||
|
return sprout::container_range_traits<Container>::range_empty(cont);
|
||||||
|
}
|
||||||
|
} // namespace container_detail
|
||||||
|
|
||||||
//
|
//
|
||||||
// empty
|
// empty
|
||||||
//
|
//
|
||||||
|
// effect:
|
||||||
|
// ADL callable range_empty(cont) -> range_empty(cont)
|
||||||
|
// otherwise -> sprout::container_range_traits<Container>::range_empty(cont)
|
||||||
|
// [default]
|
||||||
|
// callable cont.empty() -> cont.empty()
|
||||||
|
// otherwise -> size(cont) == 0
|
||||||
|
//
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
inline SPROUT_CONSTEXPR bool
|
inline SPROUT_CONSTEXPR bool
|
||||||
empty(Container const& cont) {
|
empty(Container const& cont) {
|
||||||
return sprout::begin(cont) == sprout::end(cont);
|
using sprout::container_detail::range_empty;
|
||||||
|
using sprout_adl::range_empty;
|
||||||
|
return range_empty(cont);
|
||||||
|
}
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
inline SPROUT_CONSTEXPR bool
|
||||||
|
empty(T const (& arr)[N]) {
|
||||||
|
return sprout::container_detail::range_empty(arr);
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
#include <sprout/container/container_range_traits.hpp>
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CONTAINER_EMPTY_HPP
|
#endif // #ifndef SPROUT_CONTAINER_EMPTY_HPP
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/workaround/std/cstddef.hpp>
|
#include <sprout/workaround/std/cstddef.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#include <sprout/container/container_traits.hpp>
|
#include <sprout/container/container_traits.hpp>
|
||||||
#include <sprout/container/container_range_traits.hpp>
|
|
||||||
#include <sprout/adl/not_found.hpp>
|
#include <sprout/adl/not_found.hpp>
|
||||||
|
|
||||||
namespace sprout_adl {
|
namespace sprout_adl {
|
||||||
|
@ -81,4 +81,6 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
#include <sprout/container/container_range_traits.hpp>
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CONTAINER_END_HPP
|
#endif // #ifndef SPROUT_CONTAINER_END_HPP
|
||||||
|
|
14
sprout/container/fitness_functions.hpp
Normal file
14
sprout/container/fitness_functions.hpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||||
|
https://github.com/bolero-MURAKAMI/Sprout
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
=============================================================================*/
|
||||||
|
#ifndef SPROUT_CONTAINER_FITNESS_FUNCTIONS_HPP
|
||||||
|
#define SPROUT_CONTAINER_FITNESS_FUNCTIONS_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/fit_size.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_CONTAINER_FITNESS_FUNCTIONS_HPP
|
|
@ -9,24 +9,10 @@
|
||||||
#define SPROUT_CONTAINER_FUNCTIONS_HPP
|
#define SPROUT_CONTAINER_FUNCTIONS_HPP
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/container/fixed_size.hpp>
|
#include <sprout/container/traits_functions.hpp>
|
||||||
#include <sprout/container/begin.hpp>
|
#include <sprout/container/range_functions.hpp>
|
||||||
#include <sprout/container/end.hpp>
|
#include <sprout/container/construct_functions.hpp>
|
||||||
#include <sprout/container/size.hpp>
|
#include <sprout/container/fitness_functions.hpp>
|
||||||
#include <sprout/container/empty.hpp>
|
#include <sprout/container/sub_functions.hpp>
|
||||||
#include <sprout/container/deep_copy.hpp>
|
|
||||||
#include <sprout/container/make.hpp>
|
|
||||||
#include <sprout/container/remake.hpp>
|
|
||||||
#include <sprout/container/fit_size.hpp>
|
|
||||||
#include <sprout/container/get_internal.hpp>
|
|
||||||
#include <sprout/container/get_deep_internal.hpp>
|
|
||||||
#include <sprout/container/internal_begin.hpp>
|
|
||||||
#include <sprout/container/internal_end.hpp>
|
|
||||||
#include <sprout/container/internal_size.hpp>
|
|
||||||
#include <sprout/container/internal_begin_offset.hpp>
|
|
||||||
#include <sprout/container/internal_end_offset.hpp>
|
|
||||||
#include <sprout/container/internal_begin_offset_backward.hpp>
|
|
||||||
#include <sprout/container/internal_end_offset_backward.hpp>
|
|
||||||
#include <sprout/container/internal_deep_copy.hpp>
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CONTAINER_FUNCTIONS_HPP
|
#endif // #ifndef SPROUT_CONTAINER_FUNCTIONS_HPP
|
||||||
|
|
18
sprout/container/range_functions.hpp
Normal file
18
sprout/container/range_functions.hpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||||
|
https://github.com/bolero-MURAKAMI/Sprout
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
=============================================================================*/
|
||||||
|
#ifndef SPROUT_CONTAINER_RANGE_FUNCTIONS_HPP
|
||||||
|
#define SPROUT_CONTAINER_RANGE_FUNCTIONS_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/range_functions_fwd.hpp>
|
||||||
|
#include <sprout/container/begin.hpp>
|
||||||
|
#include <sprout/container/end.hpp>
|
||||||
|
#include <sprout/container/size.hpp>
|
||||||
|
#include <sprout/container/empty.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_CONTAINER_RANGE_FUNCTIONS_HPP
|
66
sprout/container/range_functions_fwd.hpp
Normal file
66
sprout/container/range_functions_fwd.hpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||||
|
https://github.com/bolero-MURAKAMI/Sprout
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
=============================================================================*/
|
||||||
|
#ifndef SPROUT_CONTAINER_RANGE_FUNCTIONS_FWD_HPP
|
||||||
|
#define SPROUT_CONTAINER_RANGE_FUNCTIONS_FWD_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/container_traits.hpp>
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
//
|
||||||
|
// begin
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||||
|
begin(Container& cont);
|
||||||
|
template<typename Container>
|
||||||
|
SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||||
|
begin(Container const& cont);
|
||||||
|
//
|
||||||
|
// cbegin
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||||
|
cbegin(Container const& cont);
|
||||||
|
|
||||||
|
//
|
||||||
|
// end
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||||
|
end(Container& cont);
|
||||||
|
template<typename Container>
|
||||||
|
SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||||
|
end(Container const& cont);
|
||||||
|
//
|
||||||
|
// cend
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||||
|
cend(Container const& cont);
|
||||||
|
|
||||||
|
//
|
||||||
|
// size
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||||
|
size(Container const& cont);
|
||||||
|
|
||||||
|
//
|
||||||
|
// empty
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
SPROUT_CONSTEXPR bool
|
||||||
|
empty(Container const& cont);
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
|
||||||
|
#include <sprout/container/size.hpp>
|
||||||
|
#include <sprout/container/empty.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_CONTAINER_RANGE_FUNCTIONS_FWD_HPP
|
|
@ -9,20 +9,48 @@
|
||||||
#define SPROUT_CONTAINER_SIZE_HPP
|
#define SPROUT_CONTAINER_SIZE_HPP
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/workaround/std/cstddef.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#include <sprout/container/container_traits.hpp>
|
#include <sprout/container/container_traits.hpp>
|
||||||
#include <sprout/container/begin.hpp>
|
#include <sprout/adl/not_found.hpp>
|
||||||
#include <sprout/container/end.hpp>
|
|
||||||
#include <sprout/iterator/operation.hpp>
|
namespace sprout_adl {
|
||||||
|
sprout::not_found_via_adl range_size(...);
|
||||||
|
} // namespace sprout_adl
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
|
namespace container_detail {
|
||||||
|
template<typename Container>
|
||||||
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||||
|
range_size(Container const& cont) {
|
||||||
|
return sprout::container_range_traits<Container>::range_size(cont);
|
||||||
|
}
|
||||||
|
} // namespace container_detail
|
||||||
|
|
||||||
//
|
//
|
||||||
// size
|
// size
|
||||||
//
|
//
|
||||||
|
// effect:
|
||||||
|
// ADL callable range_size(cont) -> range_size(cont)
|
||||||
|
// otherwise -> sprout::container_range_traits<Container>::range_size(cont)
|
||||||
|
// [default]
|
||||||
|
// callable cont.size() -> cont.size()
|
||||||
|
// otherwise -> distance(begin(cont), end(cont))
|
||||||
|
//
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::size_type
|
||||||
size(Container const& cont) {
|
size(Container const& cont) {
|
||||||
return sprout::distance(sprout::begin(cont), sprout::end(cont));
|
using sprout::container_detail::range_size;
|
||||||
|
using sprout_adl::range_size;
|
||||||
|
return range_size(cont);
|
||||||
|
}
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::size_type
|
||||||
|
size(T const (& arr)[N]) {
|
||||||
|
return sprout::container_detail::range_size(arr);
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
#include <sprout/container/container_range_traits.hpp>
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CONTAINER_SIZE_HPP
|
#endif // #ifndef SPROUT_CONTAINER_SIZE_HPP
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/utility/forward.hpp>
|
#include <sprout/utility/forward.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
//
|
//
|
||||||
|
|
23
sprout/container/sub_functions.hpp
Normal file
23
sprout/container/sub_functions.hpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||||
|
https://github.com/bolero-MURAKAMI/Sprout
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
=============================================================================*/
|
||||||
|
#ifndef SPROUT_CONTAINER_SUB_FUNCTIONS_HPP
|
||||||
|
#define SPROUT_CONTAINER_SUB_FUNCTIONS_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/get_internal.hpp>
|
||||||
|
#include <sprout/container/get_deep_internal.hpp>
|
||||||
|
#include <sprout/container/internal_begin.hpp>
|
||||||
|
#include <sprout/container/internal_end.hpp>
|
||||||
|
#include <sprout/container/internal_size.hpp>
|
||||||
|
#include <sprout/container/internal_begin_offset.hpp>
|
||||||
|
#include <sprout/container/internal_end_offset.hpp>
|
||||||
|
#include <sprout/container/internal_begin_offset_backward.hpp>
|
||||||
|
#include <sprout/container/internal_end_offset_backward.hpp>
|
||||||
|
#include <sprout/container/internal_deep_copy.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_CONTAINER_SUB_FUNCTIONS_HPP
|
|
@ -9,6 +9,7 @@
|
||||||
#define SPROUT_CONTAINER_TRAITS_HPP
|
#define SPROUT_CONTAINER_TRAITS_HPP
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/traits_fwd.hpp>
|
||||||
#include <sprout/container/container_traits.hpp>
|
#include <sprout/container/container_traits.hpp>
|
||||||
#include <sprout/container/container_range_traits.hpp>
|
#include <sprout/container/container_range_traits.hpp>
|
||||||
#include <sprout/container/container_construct_traits.hpp>
|
#include <sprout/container/container_construct_traits.hpp>
|
||||||
|
|
14
sprout/container/traits_functions.hpp
Normal file
14
sprout/container/traits_functions.hpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||||
|
https://github.com/bolero-MURAKAMI/Sprout
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
=============================================================================*/
|
||||||
|
#ifndef SPROUT_CONTAINER_TRAITS_FUNCTIONS_HPP
|
||||||
|
#define SPROUT_CONTAINER_TRAITS_FUNCTIONS_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/container/fixed_size.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_CONTAINER_TRAITS_FUNCTIONS_HPP
|
51
sprout/container/traits_fwd.hpp
Normal file
51
sprout/container/traits_fwd.hpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||||
|
https://github.com/bolero-MURAKAMI/Sprout
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
=============================================================================*/
|
||||||
|
#ifndef SPROUT_CONTAINER_TRAITS_FWD_HPP
|
||||||
|
#define SPROUT_CONTAINER_TRAITS_FWD_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
//
|
||||||
|
// container_traits
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
struct container_traits;
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_range_traits
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
struct container_range_traits;
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_construct_traits
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
struct container_construct_traits;
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_transform_traits
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
struct container_transform_traits;
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_fitness_traits
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
struct container_fitness_traits;
|
||||||
|
|
||||||
|
//
|
||||||
|
// sub_container_traits
|
||||||
|
//
|
||||||
|
template<typename Container>
|
||||||
|
struct sub_container_traits;
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_CONTAINER_TRAITS_FWD_HPP
|
Loading…
Add table
Add a link
Reference in a new issue