mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-10-19 13:49:23 +00:00
fix container_traits for array-like classes
fix coding style algorithm/
This commit is contained in:
parent
06f1933220
commit
0c00166c5f
123 changed files with 1608 additions and 2224 deletions
|
@ -4,6 +4,26 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
sprout::adl_not_found range_begin(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline typename sprout::container_traits<Container>::iterator
|
||||
range_begin(Container& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
range_begin(Container const& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
} // namespace container_detail
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -12,19 +32,22 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline typename sprout::container_traits<Container>::iterator
|
||||
begin(Container& cont) {
|
||||
return cont.begin();
|
||||
using sprout::container_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
begin(Container const& cont) {
|
||||
using sprout::container_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<T[N]>::iterator
|
||||
begin(T (& arr)[N]) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
begin(Container const& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
begin(T const (& arr)[N]) {
|
||||
|
@ -37,7 +60,9 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
cbegin(Container const& cont) {
|
||||
return cont.begin();
|
||||
using sprout::container_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
|
|
|
@ -14,6 +14,51 @@ namespace sprout {
|
|||
struct container_traits;
|
||||
|
||||
namespace detail {
|
||||
//
|
||||
// is_array_like
|
||||
//
|
||||
template<typename Container>
|
||||
struct is_array_like
|
||||
: public std::false_type
|
||||
{};
|
||||
template<template<typename, std::size_t> class Array, typename T, std::size_t N>
|
||||
struct is_array_like<Array<T, N> >
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename Container>
|
||||
struct is_array_like<Container const>
|
||||
: public sprout::detail::is_array_like<Container>
|
||||
{};
|
||||
template<typename Container>
|
||||
struct is_array_like<Container volatile>
|
||||
: public sprout::detail::is_array_like<Container>
|
||||
{};
|
||||
template<typename Container>
|
||||
struct is_array_like<Container const volatile>
|
||||
: public sprout::detail::is_array_like<Container>
|
||||
{};
|
||||
//
|
||||
// array_like_static_size
|
||||
//
|
||||
template<typename Container>
|
||||
struct array_like_static_size {};
|
||||
template<template<typename, std::size_t> class Array, typename T, std::size_t N>
|
||||
struct array_like_static_size<Array<T, N> >
|
||||
: public std::integral_constant<std::size_t, N>
|
||||
{};
|
||||
template<typename Container>
|
||||
struct array_like_static_size<Container const>
|
||||
: public sprout::detail::array_like_static_size<Container>
|
||||
{};
|
||||
template<typename Container>
|
||||
struct array_like_static_size<Container volatile>
|
||||
: public sprout::detail::array_like_static_size<Container>
|
||||
{};
|
||||
template<typename Container>
|
||||
struct array_like_static_size<Container const volatile>
|
||||
: public sprout::detail::array_like_static_size<Container>
|
||||
{};
|
||||
|
||||
//
|
||||
// has_value_type
|
||||
// has_iterator
|
||||
|
@ -97,6 +142,17 @@ namespace sprout {
|
|||
|| sprout::detail::has_container_nosy_iterator<Container>::value
|
||||
>
|
||||
{};
|
||||
//
|
||||
// has_container_nosy_static_size
|
||||
//
|
||||
template<typename Container>
|
||||
struct has_container_nosy_static_size
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
sprout::detail::has_static_size<Container>::value
|
||||
|| sprout::detail::is_array_like<Container>::value
|
||||
>
|
||||
{};
|
||||
|
||||
//
|
||||
// container_nosy_iterator
|
||||
|
@ -346,27 +402,51 @@ namespace sprout {
|
|||
//
|
||||
// container_nosy_static_size
|
||||
//
|
||||
template<typename Container>
|
||||
struct container_nosy_static_size
|
||||
template<typename Container, bool HasStaticSize, bool IsArrayLike>
|
||||
struct container_nosy_static_size_impl {};
|
||||
template<typename Container, bool IsArrayLike>
|
||||
struct container_nosy_static_size_impl<Container, true, IsArrayLike>
|
||||
: public sprout::detail::inherit_if_static_size<Container>
|
||||
{};
|
||||
template<typename Container>
|
||||
struct container_nosy_static_size_impl<Container, false, true>
|
||||
: public sprout::detail::inherit_if_static_size<Container>
|
||||
{
|
||||
public:
|
||||
SPROUT_STATIC_CONSTEXPR typename sprout::detail::array_like_static_size<Container>::value_type static_size
|
||||
= sprout::detail::array_like_static_size<Container>::value
|
||||
;
|
||||
};
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR_OR_CONST typename sprout::detail::array_like_static_size<Container>::value_type
|
||||
sprout::detail::container_nosy_static_size_impl<Container, false, true>::static_size
|
||||
;
|
||||
template<typename Container>
|
||||
struct container_nosy_static_size
|
||||
: public sprout::detail::container_nosy_static_size_impl<
|
||||
Container,
|
||||
sprout::detail::has_static_size<Container>::value,
|
||||
sprout::detail::is_array_like<Container>::value
|
||||
>
|
||||
{};
|
||||
|
||||
//
|
||||
// container_nosy_fixed_size
|
||||
//
|
||||
template<typename Container, bool HasStaticSize>
|
||||
template<typename Container, bool HasContainerNosyStaticSize>
|
||||
struct container_nosy_fixed_size_impl {};
|
||||
template<typename Container>
|
||||
struct container_nosy_fixed_size_impl<Container, true> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(Container::static_size) fixed_size() {
|
||||
return Container::static_size;
|
||||
static SPROUT_CONSTEXPR decltype(sprout::detail::container_nosy_static_size<Container>::static_size) fixed_size() {
|
||||
return sprout::detail::container_nosy_static_size<Container>::static_size;
|
||||
}
|
||||
};
|
||||
template<typename Container>
|
||||
struct container_nosy_fixed_size
|
||||
: public sprout::detail::container_nosy_fixed_size_impl<
|
||||
Container,
|
||||
sprout::detail::has_static_size<Container>::value
|
||||
sprout::detail::has_container_nosy_static_size<Container>::value
|
||||
>
|
||||
{};
|
||||
|
||||
|
|
|
@ -4,6 +4,26 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
sprout::adl_not_found range_end(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline typename sprout::container_traits<Container>::iterator
|
||||
range_end(Container& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
range_end(Container const& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
} // namespace container_detail
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -12,19 +32,22 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline typename sprout::container_traits<Container>::iterator
|
||||
end(Container& cont) {
|
||||
return cont.end();
|
||||
using sprout::container_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
end(Container const& cont) {
|
||||
using sprout::container_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<T[N]>::iterator
|
||||
end(T (& arr)[N]) {
|
||||
return arr + N;
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
end(Container const& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
end(T const (& arr)[N]) {
|
||||
|
@ -37,7 +60,9 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
cend(Container const& cont) {
|
||||
return cont.end();
|
||||
using sprout::container_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue