1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00

fix container_traits nosy-implementation

This commit is contained in:
bolero-MURAKAMI 2012-05-11 14:24:57 +09:00
parent d4f7fa9b9c
commit 6d3f1e27c8
7 changed files with 404 additions and 88 deletions

View file

@ -2,6 +2,7 @@
#define SPROUT_CONTAINER_CONTAINER_TRAITS_HPP #define SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
#include <cstddef> #include <cstddef>
#include <iterator>
#include <array> #include <array>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
@ -13,6 +14,29 @@ namespace sprout {
struct container_traits; struct container_traits;
namespace detail { namespace detail {
//
// has_value_type
// has_iterator
// has_const_iterator
// has_reference
// has_const_reference
// has_size_type
// has_difference_type
// has_pointer
// has_const_pointer
// has_static_size
//
SPROUT_HAS_XXX_TYPE_DEF_LAZY(value_type);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(iterator);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(const_iterator);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(reference);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(const_reference);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(size_type);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(difference_type);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(pointer);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(const_pointer);
SPROUT_HAS_XXX_VALUE_DEF_LAZY(static_size);
// //
// inherit_if_value_type // inherit_if_value_type
// inherit_if_iterator // inherit_if_iterator
@ -36,52 +60,332 @@ namespace sprout {
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(const_pointer); SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(const_pointer);
SPROUT_INHERIT_IF_XXX_CONSTANT_DEF_LAZY(static_size); SPROUT_INHERIT_IF_XXX_CONSTANT_DEF_LAZY(static_size);
//
// has_static_size
//
SPROUT_HAS_XXX_VALUE_DEF_LAZY(static_size);
// //
// inherit_iterator_if_const_iterator // inherit_iterator_if_const_iterator
// inherit_const_iterator_if_iterator
// inherit_reference_if_const_reference // inherit_reference_if_const_reference
// inherit_const_reference_if_reference
// inherit_pointer_if_const_pointer // inherit_pointer_if_const_pointer
// inherit_const_pointer_if_pointer
// //
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(iterator, const_iterator); SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(iterator, const_iterator);
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(const_iterator, iterator);
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(reference, const_reference); SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(reference, const_reference);
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(const_reference, reference);
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(pointer, const_pointer); SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(pointer, const_pointer);
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(const_pointer, pointer);
// //
// inherit_if_fixed_size // has_container_nosy_iterator
// //
template<typename Container, typename Enable = void>
struct inherit_if_fixed_size {};
template<typename Container> template<typename Container>
struct inherit_if_fixed_size< struct has_container_nosy_iterator
: public std::integral_constant<
bool,
sprout::detail::has_iterator<Container>::value
|| sprout::detail::has_const_iterator<Container>::value
>
{};
//
// has_container_nosy_value_type
//
template<typename Container>
struct has_container_nosy_value_type
: public std::integral_constant<
bool,
sprout::detail::has_value_type<Container>::value
|| sprout::detail::has_container_nosy_iterator<Container>::value
>
{};
//
// container_nosy_iterator
//
template<typename Container, bool HasIterator, bool HasConstIterator>
struct container_nosy_iterator_impl {};
template<typename Container, bool HasConstIterator>
struct container_nosy_iterator_impl<Container, true, HasConstIterator>
: public sprout::detail::inherit_if_iterator<Container>
{};
template<typename Container>
struct container_nosy_iterator_impl<Container, false, true>
: public sprout::detail::inherit_iterator_if_const_iterator<Container>
{};
template<typename Container>
struct container_nosy_iterator
: public sprout::detail::container_nosy_iterator_impl<
Container, Container,
typename std::enable_if<sprout::detail::has_static_size<Container>::value>::type sprout::detail::has_iterator<Container>::value,
> { sprout::detail::has_const_iterator<Container>::value
>
{};
//
// container_nosy_const_iterator
//
template<typename Container, bool HasConstIterator, bool HasIterator>
struct container_nosy_const_iterator_impl {};
template<typename Container, bool HasIterator>
struct container_nosy_const_iterator_impl<Container, true, HasIterator>
: public sprout::detail::inherit_if_const_iterator<Container>
{};
template<typename Container>
struct container_nosy_const_iterator_impl<Container, false, true>
: public sprout::detail::inherit_const_iterator_if_iterator<Container>
{};
template<typename Container>
struct container_nosy_const_iterator
: public sprout::detail::container_nosy_const_iterator_impl<
Container,
sprout::detail::has_const_iterator<Container>::value,
sprout::detail::has_iterator<Container>::value
>
{};
//
// container_nosy_value_type
//
template<typename Container, bool HasValueType, bool HasNosyIterator>
struct container_nosy_value_type_impl {};
template<typename Container, bool HasNosyIterator>
struct container_nosy_value_type_impl<Container, true, HasNosyIterator> {
public:
typedef typename Container::value_type value_type;
};
template<typename Container>
struct container_nosy_value_type_impl<Container, false, true> {
public:
typedef typename std::iterator_traits<
typename sprout::detail::container_nosy_iterator<Container>::iterator
>::value_type value_type;
};
template<typename Container>
struct container_nosy_value_type
: public sprout::detail::container_nosy_value_type_impl<
Container,
sprout::detail::has_value_type<Container>::value,
sprout::detail::has_container_nosy_iterator<Container>::value
>
{};
//
// container_nosy_reference
//
template<typename Container, bool HasReference, bool HasConstReference, bool HasNosyIterator>
struct container_nosy_reference_impl {};
template<typename Container, bool HasConstReference, bool HasNosyIterator>
struct container_nosy_reference_impl<Container, true, HasConstReference, HasNosyIterator> {
public:
typedef typename Container::reference reference;
};
template<typename Container, bool HasNosyIterator>
struct container_nosy_reference_impl<Container, false, true, HasNosyIterator> {
public:
typedef typename Container::const_reference reference;
};
template<typename Container>
struct container_nosy_reference_impl<Container, false, false, true> {
public:
typedef typename std::iterator_traits<
typename sprout::detail::container_nosy_iterator<Container>::iterator
>::reference reference;
};
template<typename Container>
struct container_nosy_reference
: public sprout::detail::container_nosy_reference_impl<
Container,
sprout::detail::has_reference<Container>::value,
sprout::detail::has_const_reference<Container>::value,
sprout::detail::has_container_nosy_iterator<Container>::value
>
{};
//
// container_nosy_const_reference
//
template<typename Container, bool HasConstReference, bool HasReference, bool HasNosyIterator>
struct container_nosy_const_reference_impl {};
template<typename Container, bool HasReference, bool HasNosyIterator>
struct container_nosy_const_reference_impl<Container, true, HasReference, HasNosyIterator> {
public:
typedef typename Container::const_reference const_reference;
};
template<typename Container, bool HasNosyIterator>
struct container_nosy_const_reference_impl<Container, false, true, HasNosyIterator> {
public:
typedef typename Container::reference const_reference;
};
template<typename Container>
struct container_nosy_const_reference_impl<Container, false, false, true> {
public:
typedef typename std::iterator_traits<
typename sprout::detail::container_nosy_const_iterator<Container>::const_iterator
>::reference const_reference;
};
template<typename Container>
struct container_nosy_const_reference
: public sprout::detail::container_nosy_const_reference_impl<
Container,
sprout::detail::has_const_reference<Container>::value,
sprout::detail::has_reference<Container>::value,
sprout::detail::has_container_nosy_iterator<Container>::value
>
{};
//
// container_nosy_difference_type
//
template<typename Container, bool HasDifferenceType, bool HasNosyIterator>
struct container_nosy_difference_type_impl {
public:
typedef std::ptrdiff_t difference_type;
};
template<typename Container, bool HasNosyIterator>
struct container_nosy_difference_type_impl<Container, true, HasNosyIterator> {
public:
typedef typename Container::difference_type difference_type;
};
template<typename Container>
struct container_nosy_difference_type_impl<Container, false, true> {
public:
typedef typename std::iterator_traits<
typename sprout::detail::container_nosy_iterator<Container>::iterator
>::difference_type difference_type;
};
template<typename Container>
struct container_nosy_difference_type
: public sprout::detail::container_nosy_difference_type_impl<
Container,
sprout::detail::has_difference_type<Container>::value,
sprout::detail::has_container_nosy_iterator<Container>::value
>
{};
//
// container_nosy_size_type
//
template<typename Container, bool HasSizeType, bool HasNosyIterator>
struct container_nosy_size_type_impl {
public:
typedef std::size_t size_type;
};
template<typename Container, bool HasNosyIterator>
struct container_nosy_size_type_impl<Container, true, HasNosyIterator> {
public:
typedef typename Container::size_type size_type;
};
template<typename Container>
struct container_nosy_size_type_impl<Container, false, true> {
public:
typedef typename std::make_unsigned<
typename std::iterator_traits<
typename sprout::detail::container_nosy_iterator<Container>::iterator
>::difference_type
>::type size_type;
};
template<typename Container>
struct container_nosy_size_type
: public sprout::detail::container_nosy_size_type_impl<
Container,
sprout::detail::has_size_type<Container>::value,
sprout::detail::has_container_nosy_iterator<Container>::value
>
{};
//
// container_nosy_pointer
//
template<typename Container, bool HasPointer, bool HasConstPointer, bool HasNosyValueType>
struct container_nosy_pointer_impl {};
template<typename Container, bool HasConstPointer, bool HasNosyValueType>
struct container_nosy_pointer_impl<Container, true, HasConstPointer, HasNosyValueType> {
public:
typedef typename Container::pointer pointer;
};
template<typename Container, bool HasNosyValueType>
struct container_nosy_pointer_impl<Container, false, true, HasNosyValueType> {
public:
typedef typename Container::const_pointer pointer;
};
template<typename Container>
struct container_nosy_pointer_impl<Container, false, false, true> {
public:
typedef typename sprout::detail::container_nosy_value_type<Container>::value_type* pointer;
};
template<typename Container>
struct container_nosy_pointer
: public sprout::detail::container_nosy_pointer_impl<
Container,
sprout::detail::has_pointer<Container>::value,
sprout::detail::has_const_pointer<Container>::value,
sprout::detail::has_container_nosy_value_type<Container>::value
>
{};
//
// container_nosy_const_pointer
//
template<typename Container, bool HasConstPointer, bool HasPointer, bool HasNosyValueType>
struct container_nosy_const_pointer_impl {};
template<typename Container, bool HasPointer, bool HasNosyValueType>
struct container_nosy_const_pointer_impl<Container, true, HasPointer, HasNosyValueType> {
public:
typedef typename Container::const_pointer const_pointer;
};
template<typename Container, bool HasNosyValueType>
struct container_nosy_const_pointer_impl<Container, false, true, HasNosyValueType> {
public:
typedef typename Container::pointer const_pointer;
};
template<typename Container>
struct container_nosy_const_pointer_impl<Container, false, false, true> {
public:
typedef typename sprout::detail::container_nosy_value_type<Container>::value_type const* const_pointer;
};
template<typename Container>
struct container_nosy_const_pointer
: public sprout::detail::container_nosy_const_pointer_impl<
Container,
sprout::detail::has_const_pointer<Container>::value,
sprout::detail::has_pointer<Container>::value,
sprout::detail::has_container_nosy_value_type<Container>::value
>
{};
//
// container_nosy_static_size
//
template<typename Container>
struct container_nosy_static_size
: public sprout::detail::inherit_if_static_size<Container>
{};
//
// container_nosy_fixed_size
//
template<typename Container, bool HasStaticSize>
struct container_nosy_fixed_size_impl {};
template<typename Container>
struct container_nosy_fixed_size_impl<Container, true> {
public: public:
static SPROUT_CONSTEXPR decltype(Container::static_size) fixed_size() { static SPROUT_CONSTEXPR decltype(Container::static_size) fixed_size() {
return Container::static_size; return 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
>
{};
// //
// container_traits_default // container_traits_default
// //
template<typename Container> template<typename Container>
struct container_traits_default struct container_traits_default
: public sprout::detail::inherit_if_value_type<Container> : public sprout::detail::container_nosy_value_type<Container>
, public sprout::detail::inherit_if_iterator<Container> , public sprout::detail::container_nosy_iterator<Container>
, public sprout::detail::inherit_if_const_iterator<Container> , public sprout::detail::container_nosy_const_iterator<Container>
, public sprout::detail::inherit_if_reference<Container> , public sprout::detail::container_nosy_reference<Container>
, public sprout::detail::inherit_if_const_reference<Container> , public sprout::detail::container_nosy_const_reference<Container>
, public sprout::detail::inherit_if_size_type<Container> , public sprout::detail::container_nosy_size_type<Container>
, public sprout::detail::inherit_if_difference_type<Container> , public sprout::detail::container_nosy_difference_type<Container>
, public sprout::detail::inherit_if_pointer<Container> , public sprout::detail::container_nosy_pointer<Container>
, public sprout::detail::inherit_if_const_pointer<Container> , public sprout::detail::container_nosy_const_pointer<Container>
, public sprout::detail::inherit_if_static_size<Container> , public sprout::detail::container_nosy_static_size<Container>
, public sprout::detail::inherit_if_fixed_size<Container> , public sprout::detail::container_nosy_fixed_size<Container>
{}; {};
template<typename T, std::size_t N> template<typename T, std::size_t N>
struct container_traits_default<T[N]> { struct container_traits_default<T[N]> {
@ -115,7 +419,7 @@ namespace sprout {
, public sprout::detail::inherit_if_difference_type<sprout::container_traits<Container> > , public sprout::detail::inherit_if_difference_type<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_const_pointer<sprout::container_traits<Container> > , public sprout::detail::inherit_if_const_pointer<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_static_size<sprout::container_traits<Container> > , public sprout::detail::inherit_if_static_size<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_fixed_size<sprout::container_traits<Container> > , public sprout::detail::container_nosy_fixed_size<sprout::container_traits<Container> >
, public sprout::detail::inherit_iterator_if_const_iterator<sprout::container_traits<Container> > , public sprout::detail::inherit_iterator_if_const_iterator<sprout::container_traits<Container> >
, public sprout::detail::inherit_reference_if_const_reference<sprout::container_traits<Container> > , public sprout::detail::inherit_reference_if_const_reference<sprout::container_traits<Container> >
, public sprout::detail::inherit_pointer_if_const_pointer<sprout::container_traits<Container> > , public sprout::detail::inherit_pointer_if_const_pointer<sprout::container_traits<Container> >
@ -142,6 +446,24 @@ namespace sprout {
struct container_traits<T const[N]> struct container_traits<T const[N]>
: public sprout::detail::container_traits_const_default<T[N]> : public sprout::detail::container_traits_const_default<T[N]>
{}; {};
//
// container_traits_facade
//
template<typename Container>
struct container_traits_facade
: public sprout::detail::inherit_if_value_type<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_iterator<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_const_iterator<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_reference<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_const_reference<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_size_type<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_difference_type<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_pointer<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_const_pointer<sprout::container_traits<Container> >
, public sprout::detail::inherit_if_static_size<sprout::container_traits<Container> >
, public sprout::detail::container_nosy_fixed_size<sprout::container_traits<Container> >
{};
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP #endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP

View file

@ -25,7 +25,7 @@ namespace sprout {
: public sprout::range::range_container< : public sprout::range::range_container<
typename sprout::container_traits<Range>::iterator typename sprout::container_traits<Range>::iterator
> >
, public sprout::detail::inherit_if_fixed_size<Range> , public sprout::detail::container_nosy_fixed_size<Range>
{ {
public: public:
typedef Range range_type; typedef Range range_type;

View file

@ -23,7 +23,7 @@ namespace sprout {
: public sprout::range::range_container< : public sprout::range::range_container<
sprout::sinusoid_iterator<Value> sprout::sinusoid_iterator<Value>
> >
, public sprout::detail::inherit_if_fixed_size<Range> , public sprout::detail::container_nosy_fixed_size<Range>
{ {
public: public:
typedef Range range_type; typedef Range range_type;

View file

@ -28,7 +28,7 @@ namespace sprout {
typename sprout::container_traits<RRange>::iterator typename sprout::container_traits<RRange>::iterator
> >
> >
, public sprout::detail::inherit_if_fixed_size<LRange> , public sprout::detail::container_nosy_fixed_size<LRange>
{ {
public: public:
typedef BinaryFunction functor_type; typedef BinaryFunction functor_type;
@ -62,7 +62,7 @@ namespace sprout {
typename sprout::container_traits<Range>::iterator typename sprout::container_traits<Range>::iterator
> >
> >
, public sprout::detail::inherit_if_fixed_size<Range> , public sprout::detail::container_nosy_fixed_size<Range>
{ {
public: public:
typedef UnaryFunction functor_type; typedef UnaryFunction functor_type;

View file

@ -28,29 +28,8 @@ namespace sprout {
SPROUT_STATIC_CONSTEXPR bool is_reference = std::is_reference<container_type>::value; SPROUT_STATIC_CONSTEXPR bool is_reference = std::is_reference<container_type>::value;
SPROUT_STATIC_CONSTEXPR bool is_const = std::is_const<internal_type>::value; SPROUT_STATIC_CONSTEXPR bool is_const = std::is_const<internal_type>::value;
protected: protected:
typedef typename sprout::container_traits<internal_type>::value_type value_type; typedef typename sprout::container_traits<internal_type>::const_iterator impl_const_iterator;
typedef typename std::conditional< typedef typename sprout::container_traits<internal_type>::difference_type impl_difference_type;
is_const,
typename sprout::container_traits<internal_type>::const_iterator,
typename sprout::container_traits<internal_type>::iterator
>::type iterator;
typedef typename sprout::container_traits<internal_type>::const_iterator const_iterator;
typedef typename std::conditional<
is_const,
typename sprout::container_traits<internal_type>::const_reference,
typename sprout::container_traits<internal_type>::reference
>::type reference;
typedef typename sprout::container_traits<internal_type>::const_reference const_reference;
typedef typename sprout::container_traits<internal_type>::size_type size_type;
typedef typename sprout::container_traits<internal_type>::difference_type difference_type;
typedef typename std::conditional<
is_const,
typename sprout::container_traits<internal_type>::const_pointer,
typename sprout::container_traits<internal_type>::pointer
>::type pointer;
typedef typename sprout::container_traits<internal_type>::const_pointer const_pointer;
protected:
SPROUT_STATIC_CONSTEXPR size_type static_size = sprout::container_traits<internal_type>::static_size;
protected: protected:
typedef typename std::conditional< typedef typename std::conditional<
is_reference, is_reference,
@ -121,8 +100,8 @@ namespace sprout {
} }
protected: protected:
holder_type array_; holder_type array_;
difference_type first_; impl_difference_type first_;
difference_type last_; impl_difference_type last_;
public: public:
sub_array_impl() = default; sub_array_impl() = default;
protected: protected:
@ -131,8 +110,8 @@ namespace sprout {
ContainerTag, ContainerTag,
param_type arr, param_type arr,
sprout::index_tuple<Indexes...>, sprout::index_tuple<Indexes...>,
const_iterator first, impl_const_iterator first,
const_iterator last, impl_const_iterator last,
typename std::enable_if<std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0 typename std::enable_if<std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0
) )
: array_{to_holder<Container>(arr)[Indexes]...} : array_{to_holder<Container>(arr)[Indexes]...}
@ -144,8 +123,8 @@ namespace sprout {
ContainerTag, ContainerTag,
param_type arr, param_type arr,
sprout::index_tuple<Indexes...>, sprout::index_tuple<Indexes...>,
const_iterator first, impl_const_iterator first,
const_iterator last, impl_const_iterator last,
typename std::enable_if<!std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0 typename std::enable_if<!std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0
) )
: array_(to_holder<Container>(arr)) : array_(to_holder<Container>(arr))
@ -157,8 +136,8 @@ namespace sprout {
ContainerTag, ContainerTag,
param_type arr, param_type arr,
sprout::index_tuple<Indexes...>, sprout::index_tuple<Indexes...>,
difference_type first, impl_difference_type first,
difference_type last, impl_difference_type last,
typename std::enable_if<std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0 typename std::enable_if<std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0
) )
: array_{to_holder<Container>(arr)[Indexes]...} : array_{to_holder<Container>(arr)[Indexes]...}
@ -170,8 +149,8 @@ namespace sprout {
ContainerTag, ContainerTag,
param_type arr, param_type arr,
sprout::index_tuple<Indexes...>, sprout::index_tuple<Indexes...>,
difference_type first, impl_difference_type first,
difference_type last, impl_difference_type last,
typename std::enable_if<!std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0 typename std::enable_if<!std::is_same<ContainerTag, sprout::detail::is_non_reference_array_tag>::value>::type* = 0
) )
: array_(to_holder<Container>(arr)) : array_(to_holder<Container>(arr))
@ -187,9 +166,11 @@ namespace sprout {
template<typename Container> template<typename Container>
class sub_array class sub_array
: private sprout::detail::sub_array_impl<Container> : private sprout::detail::sub_array_impl<Container>
, public sprout::container_traits_facade<typename std::remove_reference<Container>::type>
{ {
private: private:
typedef sprout::detail::sub_array_impl<Container> impl_type; typedef sprout::detail::sub_array_impl<Container> impl_type;
typedef sprout::container_traits_facade<typename std::remove_reference<Container>::type> facade_type;
public: public:
typedef typename impl_type::container_type container_type; typedef typename impl_type::container_type container_type;
typedef typename impl_type::internal_type internal_type; typedef typename impl_type::internal_type internal_type;
@ -197,17 +178,16 @@ namespace sprout {
SPROUT_STATIC_CONSTEXPR bool is_reference = impl_type::is_reference; SPROUT_STATIC_CONSTEXPR bool is_reference = impl_type::is_reference;
SPROUT_STATIC_CONSTEXPR bool is_const = impl_type::is_const; SPROUT_STATIC_CONSTEXPR bool is_const = impl_type::is_const;
public: public:
typedef typename impl_type::value_type value_type; typedef typename facade_type::iterator iterator;
typedef typename impl_type::iterator iterator; typedef typename facade_type::const_iterator const_iterator;
typedef typename impl_type::const_iterator const_iterator; typedef typename facade_type::reference reference;
typedef typename impl_type::reference reference; typedef typename facade_type::const_reference const_reference;
typedef typename impl_type::const_reference const_reference; typedef typename facade_type::size_type size_type;
typedef typename impl_type::size_type size_type; typedef typename facade_type::difference_type difference_type;
typedef typename impl_type::difference_type difference_type; typedef typename facade_type::pointer pointer;
typedef typename impl_type::pointer pointer; typedef typename facade_type::const_pointer const_pointer;
typedef typename impl_type::const_pointer const_pointer;
public: public:
SPROUT_STATIC_CONSTEXPR size_type static_size = impl_type::static_size; SPROUT_STATIC_CONSTEXPR size_type static_size = facade_type::static_size;
public: public:
typedef typename impl_type::holder_type holder_type; typedef typename impl_type::holder_type holder_type;
typedef typename impl_type::param_type param_type; typedef typename impl_type::param_type param_type;
@ -378,6 +358,14 @@ namespace sprout {
template<typename Container> template<typename Container>
SPROUT_CONSTEXPR typename sprout::sub_array<Container>::size_type sprout::sub_array<Container>::static_size; SPROUT_CONSTEXPR typename sprout::sub_array<Container>::size_type sprout::sub_array<Container>::static_size;
//
// swap
//
template<typename Container>
inline void swap(sprout::sub_array<Container>& lhs, sprout::sub_array<Container>& rhs) {
lhs.swap(rhs);
}
// //
// operator== // operator==
// operator!= // operator!=
@ -387,38 +375,39 @@ namespace sprout {
// operator>= // operator>=
// //
template<typename Container> template<typename Container>
inline SPROUT_CONSTEXPR bool operator==(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) { inline SPROUT_CONSTEXPR bool
operator==(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) {
return NS_SSCRISK_CEL_OR_SPROUT::equal(sprout::begin(lhs), sprout::end(lhs), sprout::begin(rhs)); return NS_SSCRISK_CEL_OR_SPROUT::equal(sprout::begin(lhs), sprout::end(lhs), sprout::begin(rhs));
} }
template<typename Container> template<typename Container>
inline SPROUT_CONSTEXPR bool operator!=(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) { inline SPROUT_CONSTEXPR bool
operator!=(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
template<typename Container> template<typename Container>
inline SPROUT_CONSTEXPR bool operator<(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) { inline SPROUT_CONSTEXPR bool
return NS_SSCRISK_CEL_OR_SPROUT::lexicographical_compare(sprout::begin(lhs), sprout::end(lhs), sprout::begin(rhs), sprout::end(rhs)); operator<(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) {
return NS_SSCRISK_CEL_OR_SPROUT::lexicographical_compare(
sprout::begin(lhs), sprout::end(lhs),
sprout::begin(rhs), sprout::end(rhs)
);
} }
template<typename Container> template<typename Container>
inline SPROUT_CONSTEXPR bool operator>(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) { inline SPROUT_CONSTEXPR bool
operator>(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) {
return rhs < lhs; return rhs < lhs;
} }
template<typename Container> template<typename Container>
inline SPROUT_CONSTEXPR bool operator<=(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) { inline SPROUT_CONSTEXPR bool
operator<=(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) {
return !(rhs < lhs); return !(rhs < lhs);
} }
template<typename Container> template<typename Container>
inline SPROUT_CONSTEXPR bool operator>=(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) { inline SPROUT_CONSTEXPR bool
operator>=(sprout::sub_array<Container> const& lhs, sprout::sub_array<Container> const& rhs) {
return !(lhs < rhs); return !(lhs < rhs);
} }
//
// swap
//
template<typename Container>
inline void swap(sprout::sub_array<Container>& lhs, sprout::sub_array<Container>& rhs) {
lhs.swap(rhs);
}
// //
// container_construct_traits // container_construct_traits
// //

View file

@ -41,6 +41,6 @@
// SPROUT_HAS_XXX_VALUE_DEF_LAZY // SPROUT_HAS_XXX_VALUE_DEF_LAZY
// //
#define SPROUT_HAS_XXX_VALUE_DEF_LAZY(VALUE) \ #define SPROUT_HAS_XXX_VALUE_DEF_LAZY(VALUE) \
SPROUT_HAS_XXX_TYPE_DEF(SPROUT_PP_CAT(has_, VALUE), VALUE) SPROUT_HAS_XXX_VALUE_DEF(SPROUT_PP_CAT(has_, VALUE), VALUE)
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_XXX_HPP #endif // #ifndef SPROUT_TYPE_TRAITS_HAS_XXX_HPP

View file

@ -49,7 +49,12 @@
> { \ > { \
public: \ public: \
SPROUT_STATIC_CONSTEXPR decltype(T::CONSTANT) ALIAS = T::CONSTANT; \ SPROUT_STATIC_CONSTEXPR decltype(T::CONSTANT) ALIAS = T::CONSTANT; \
} }; \
template<typename T> \
SPROUT_CONSTEXPR decltype(T::CONSTANT) NAME< \
T, \
typename std::enable_if<SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_inherit_if_xxx_constant_def_impl_has_, CONSTANT), __LINE__)<T>::value>::type \
>::ALIAS
#define SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF_LAZY(ALIAS, CONSTANT) \ #define SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF_LAZY(ALIAS, CONSTANT) \
SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(inherit_, ALIAS), _if_), CONSTANT), ALIAS, CONSTANT) SPROUT_INHERIT_ALIAS_IF_XXX_CONSTANT_DEF(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(inherit_, ALIAS), _if_), CONSTANT), ALIAS, CONSTANT)