2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
|
|
|
Copyright (c) 2011-2013 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)
|
|
|
|
=============================================================================*/
|
2012-03-31 07:24:13 +00:00
|
|
|
#ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
|
|
|
|
#define SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
|
|
|
|
|
|
|
|
#include <cstddef>
|
2012-05-11 05:24:57 +00:00
|
|
|
#include <iterator>
|
2012-03-31 07:24:13 +00:00
|
|
|
#include <array>
|
2012-04-30 01:55:33 +00:00
|
|
|
#include <type_traits>
|
2012-03-31 07:24:13 +00:00
|
|
|
#include <sprout/config.hpp>
|
2013-11-22 12:11:08 +00:00
|
|
|
#include <sprout/type_traits/integral_constant.hpp>
|
2012-04-30 01:55:33 +00:00
|
|
|
#include <sprout/type_traits/has_xxx.hpp>
|
|
|
|
#include <sprout/type_traits/inherit_if_xxx.hpp>
|
2012-10-05 15:58:56 +00:00
|
|
|
#include <sprout/container/detail/array_like.hpp>
|
2012-12-21 13:35:48 +00:00
|
|
|
#if SPROUT_USE_PTR_INDEX_ITERATOR_IMPLEMENTATION
|
|
|
|
# include <sprout/iterator/ptr_index_iterator.hpp>
|
|
|
|
#endif
|
2014-01-07 15:47:39 +00:00
|
|
|
#include <sprout/workaround/base_class_construct.hpp>
|
2012-03-31 07:24:13 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
template<typename Container>
|
|
|
|
struct container_traits;
|
|
|
|
|
|
|
|
namespace detail {
|
2012-05-11 05:24:57 +00:00
|
|
|
//
|
|
|
|
// 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);
|
|
|
|
|
2012-04-30 01:55:33 +00:00
|
|
|
//
|
|
|
|
// inherit_if_value_type
|
|
|
|
// inherit_if_iterator
|
|
|
|
// inherit_if_const_iterator
|
|
|
|
// inherit_if_reference
|
|
|
|
// inherit_if_const_reference
|
|
|
|
// inherit_if_size_type
|
|
|
|
// inherit_if_difference_type
|
|
|
|
// inherit_if_pointer
|
2012-05-11 00:23:01 +00:00
|
|
|
// inherit_if_const_pointer
|
2012-04-30 01:55:33 +00:00
|
|
|
// inherit_if_static_size
|
|
|
|
//
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(value_type);
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(iterator);
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(const_iterator);
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(reference);
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(const_reference);
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(size_type);
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(difference_type);
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(pointer);
|
|
|
|
SPROUT_INHERIT_IF_XXX_TYPE_DEF_LAZY(const_pointer);
|
|
|
|
SPROUT_INHERIT_IF_XXX_CONSTANT_DEF_LAZY(static_size);
|
|
|
|
|
2012-05-11 00:23:01 +00:00
|
|
|
//
|
|
|
|
// inherit_iterator_if_const_iterator
|
2012-05-11 05:24:57 +00:00
|
|
|
// inherit_const_iterator_if_iterator
|
2012-05-11 00:23:01 +00:00
|
|
|
// inherit_reference_if_const_reference
|
2012-05-11 05:24:57 +00:00
|
|
|
// inherit_const_reference_if_reference
|
2012-05-11 00:23:01 +00:00
|
|
|
// inherit_pointer_if_const_pointer
|
2012-05-11 05:24:57 +00:00
|
|
|
// inherit_const_pointer_if_pointer
|
2012-05-11 00:23:01 +00:00
|
|
|
//
|
|
|
|
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(iterator, const_iterator);
|
2012-05-11 05:24:57 +00:00
|
|
|
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(const_iterator, iterator);
|
2012-05-11 00:23:01 +00:00
|
|
|
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(reference, const_reference);
|
2012-05-11 05:24:57 +00:00
|
|
|
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(const_reference, reference);
|
2012-05-11 00:23:01 +00:00
|
|
|
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(pointer, const_pointer);
|
2012-05-11 05:24:57 +00:00
|
|
|
SPROUT_INHERIT_ALIAS_IF_XXX_TYPE_DEF_LAZY(const_pointer, pointer);
|
2012-05-11 00:23:01 +00:00
|
|
|
|
|
|
|
//
|
2012-05-11 05:24:57 +00:00
|
|
|
// has_container_nosy_iterator
|
|
|
|
//
|
|
|
|
template<typename Container>
|
|
|
|
struct has_container_nosy_iterator
|
2013-11-22 12:11:08 +00:00
|
|
|
: public sprout::integral_constant<
|
2012-05-11 05:24:57 +00:00
|
|
|
bool,
|
|
|
|
sprout::detail::has_iterator<Container>::value
|
|
|
|
|| sprout::detail::has_const_iterator<Container>::value
|
|
|
|
>
|
|
|
|
{};
|
|
|
|
//
|
|
|
|
// has_container_nosy_value_type
|
2012-05-11 00:23:01 +00:00
|
|
|
//
|
2012-03-31 07:24:13 +00:00
|
|
|
template<typename Container>
|
2012-05-11 05:24:57 +00:00
|
|
|
struct has_container_nosy_value_type
|
2013-11-22 12:11:08 +00:00
|
|
|
: public sprout::integral_constant<
|
2012-05-11 05:24:57 +00:00
|
|
|
bool,
|
|
|
|
sprout::detail::has_value_type<Container>::value
|
|
|
|
|| sprout::detail::has_container_nosy_iterator<Container>::value
|
|
|
|
>
|
|
|
|
{};
|
2012-09-29 08:10:46 +00:00
|
|
|
//
|
|
|
|
// has_container_nosy_static_size
|
|
|
|
//
|
|
|
|
template<typename Container>
|
|
|
|
struct has_container_nosy_static_size
|
2013-11-22 12:11:08 +00:00
|
|
|
: public sprout::integral_constant<
|
2012-09-29 08:10:46 +00:00
|
|
|
bool,
|
|
|
|
sprout::detail::has_static_size<Container>::value
|
|
|
|
|| sprout::detail::is_array_like<Container>::value
|
|
|
|
>
|
|
|
|
{};
|
2012-05-11 05:24:57 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// 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,
|
|
|
|
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
|
|
|
|
//
|
2012-09-29 08:10:46 +00:00
|
|
|
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>
|
|
|
|
{};
|
2012-05-11 05:24:57 +00:00
|
|
|
template<typename Container>
|
2012-09-29 08:10:46 +00:00
|
|
|
struct container_nosy_static_size_impl<Container, false, true>
|
2012-05-11 05:24:57 +00:00
|
|
|
: public sprout::detail::inherit_if_static_size<Container>
|
2012-09-29 08:10:46 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
>
|
2012-05-11 05:24:57 +00:00
|
|
|
{};
|
2012-09-29 08:10:46 +00:00
|
|
|
|
2012-05-11 05:24:57 +00:00
|
|
|
//
|
|
|
|
// container_nosy_fixed_size
|
|
|
|
//
|
2012-09-29 08:10:46 +00:00
|
|
|
template<typename Container, bool HasContainerNosyStaticSize>
|
2012-05-11 05:24:57 +00:00
|
|
|
struct container_nosy_fixed_size_impl {};
|
|
|
|
template<typename Container>
|
|
|
|
struct container_nosy_fixed_size_impl<Container, true> {
|
2012-03-31 07:24:13 +00:00
|
|
|
public:
|
2012-10-05 15:58:56 +00:00
|
|
|
static SPROUT_CONSTEXPR decltype(sprout::detail::container_nosy_static_size<Container>::static_size)
|
2012-11-18 14:32:36 +00:00
|
|
|
fixed_size() SPROUT_NOEXCEPT {
|
2012-09-29 08:10:46 +00:00
|
|
|
return sprout::detail::container_nosy_static_size<Container>::static_size;
|
2012-04-30 01:55:33 +00:00
|
|
|
}
|
2012-03-31 07:24:13 +00:00
|
|
|
};
|
2012-05-11 05:24:57 +00:00
|
|
|
template<typename Container>
|
|
|
|
struct container_nosy_fixed_size
|
|
|
|
: public sprout::detail::container_nosy_fixed_size_impl<
|
|
|
|
Container,
|
2012-09-29 08:10:46 +00:00
|
|
|
sprout::detail::has_container_nosy_static_size<Container>::value
|
2012-10-05 15:58:56 +00:00
|
|
|
>
|
2012-05-11 05:24:57 +00:00
|
|
|
{};
|
2012-04-30 01:55:33 +00:00
|
|
|
|
2012-05-11 00:23:01 +00:00
|
|
|
//
|
|
|
|
// container_traits_default
|
|
|
|
//
|
2012-04-30 01:55:33 +00:00
|
|
|
template<typename Container>
|
|
|
|
struct container_traits_default
|
2012-05-11 05:24:57 +00:00
|
|
|
: public sprout::detail::container_nosy_value_type<Container>
|
|
|
|
, public sprout::detail::container_nosy_iterator<Container>
|
|
|
|
, public sprout::detail::container_nosy_const_iterator<Container>
|
|
|
|
, public sprout::detail::container_nosy_reference<Container>
|
|
|
|
, public sprout::detail::container_nosy_const_reference<Container>
|
|
|
|
, public sprout::detail::container_nosy_size_type<Container>
|
|
|
|
, public sprout::detail::container_nosy_difference_type<Container>
|
|
|
|
, public sprout::detail::container_nosy_pointer<Container>
|
|
|
|
, public sprout::detail::container_nosy_const_pointer<Container>
|
|
|
|
, public sprout::detail::container_nosy_static_size<Container>
|
|
|
|
, public sprout::detail::container_nosy_fixed_size<Container>
|
2012-04-30 01:55:33 +00:00
|
|
|
{};
|
2012-03-31 07:24:13 +00:00
|
|
|
template<typename T, std::size_t N>
|
2012-04-30 01:55:33 +00:00
|
|
|
struct container_traits_default<T[N]> {
|
2012-03-31 07:24:13 +00:00
|
|
|
public:
|
|
|
|
typedef T value_type;
|
2012-12-21 13:35:48 +00:00
|
|
|
#if SPROUT_USE_PTR_INDEX_ITERATOR_IMPLEMENTATION
|
2013-02-18 17:49:10 +00:00
|
|
|
typedef sprout::ptr_index_iterator<T, true> iterator;
|
|
|
|
typedef sprout::ptr_index_iterator<T const, true> const_iterator;
|
2012-12-21 13:35:48 +00:00
|
|
|
#else
|
2012-03-31 07:24:13 +00:00
|
|
|
typedef T* iterator;
|
|
|
|
typedef T const* const_iterator;
|
2012-12-21 13:35:48 +00:00
|
|
|
#endif
|
2012-03-31 07:24:13 +00:00
|
|
|
typedef T& reference;
|
|
|
|
typedef T const& const_reference;
|
|
|
|
typedef std::size_t size_type;
|
|
|
|
typedef std::ptrdiff_t difference_type;
|
|
|
|
typedef T* pointer;
|
|
|
|
typedef T const* const_pointer;
|
|
|
|
public:
|
2013-03-22 05:24:19 +00:00
|
|
|
SPROUT_STATIC_CONSTEXPR size_type static_size = N;
|
2012-03-31 07:24:13 +00:00
|
|
|
public:
|
2012-10-05 15:58:56 +00:00
|
|
|
static SPROUT_CONSTEXPR size_type
|
2012-11-18 14:32:36 +00:00
|
|
|
fixed_size() SPROUT_NOEXCEPT {
|
2012-03-31 07:24:13 +00:00
|
|
|
return static_size;
|
|
|
|
}
|
|
|
|
};
|
2012-06-15 15:08:42 +00:00
|
|
|
template<typename T, std::size_t N>
|
|
|
|
SPROUT_CONSTEXPR_OR_CONST typename sprout::detail::container_traits_default<T[N]>::size_type
|
|
|
|
sprout::detail::container_traits_default<T[N]>::static_size;
|
2012-05-11 00:23:01 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// container_traits_const_default
|
|
|
|
//
|
|
|
|
template<typename Container>
|
|
|
|
struct container_traits_const_default
|
|
|
|
: public sprout::detail::inherit_if_value_type<sprout::container_traits<Container> >
|
|
|
|
, public sprout::detail::inherit_if_const_iterator<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_const_pointer<sprout::container_traits<Container> >
|
|
|
|
, public sprout::detail::inherit_if_static_size<sprout::container_traits<Container> >
|
2012-05-11 05:24:57 +00:00
|
|
|
, public sprout::detail::container_nosy_fixed_size<sprout::container_traits<Container> >
|
2012-05-11 00:23:01 +00:00
|
|
|
, 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_pointer_if_const_pointer<sprout::container_traits<Container> >
|
|
|
|
{};
|
2012-03-31 07:24:13 +00:00
|
|
|
} // namespace detail
|
|
|
|
|
2012-04-30 01:55:33 +00:00
|
|
|
//
|
|
|
|
// container_traits
|
|
|
|
//
|
2012-03-31 07:24:13 +00:00
|
|
|
template<typename Container>
|
|
|
|
struct container_traits
|
2012-04-30 01:55:33 +00:00
|
|
|
: public sprout::detail::container_traits_default<Container>
|
2012-03-31 07:24:13 +00:00
|
|
|
{};
|
|
|
|
template<typename Container>
|
|
|
|
struct container_traits<Container const>
|
2012-05-11 00:23:01 +00:00
|
|
|
: public sprout::detail::container_traits_const_default<Container>
|
|
|
|
{};
|
2012-03-31 07:24:13 +00:00
|
|
|
|
|
|
|
template<typename T, std::size_t N>
|
|
|
|
struct container_traits<T[N]>
|
2012-04-30 01:55:33 +00:00
|
|
|
: public sprout::detail::container_traits_default<T[N]>
|
2012-03-31 07:24:13 +00:00
|
|
|
{};
|
|
|
|
template<typename T, std::size_t N>
|
|
|
|
struct container_traits<T const[N]>
|
2012-05-11 00:23:01 +00:00
|
|
|
: public sprout::detail::container_traits_const_default<T[N]>
|
|
|
|
{};
|
2012-05-11 05:24:57 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// 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> >
|
2014-01-07 15:47:39 +00:00
|
|
|
{
|
|
|
|
#if SPROUT_NEEDS_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT
|
|
|
|
public:
|
|
|
|
SPROUT_CONSTEXPR container_traits_facade()
|
|
|
|
: SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_value_type<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_iterator<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_const_iterator<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_reference<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_const_reference<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_size_type<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_difference_type<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_pointer<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_const_pointer<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::inherit_if_static_size<sprout::container_traits<Container> >)
|
|
|
|
, SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT(sprout::detail::container_nosy_fixed_size<sprout::container_traits<Container> >)
|
|
|
|
{}
|
|
|
|
#endif
|
|
|
|
};
|
2013-01-13 16:13:48 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// is_fixed_container
|
|
|
|
//
|
|
|
|
template<typename Container>
|
|
|
|
struct is_fixed_container
|
|
|
|
: public sprout::detail::has_static_size<sprout::container_traits<Container> >
|
|
|
|
{};
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
//
|
|
|
|
// static_size_or_zero
|
|
|
|
//
|
|
|
|
template<typename Container, typename = void>
|
|
|
|
struct static_size_or_zero;
|
|
|
|
template<typename Container>
|
|
|
|
struct static_size_or_zero<
|
|
|
|
Container,
|
|
|
|
typename std::enable_if<sprout::is_fixed_container<sprout::container_traits<Container> >::value>::type
|
|
|
|
>
|
2013-11-22 12:11:08 +00:00
|
|
|
: public sprout::integral_constant<
|
2013-01-13 16:13:48 +00:00
|
|
|
typename sprout::container_traits<Container>::size_type,
|
|
|
|
sprout::container_traits<Container>::static_size
|
|
|
|
>
|
|
|
|
{};
|
|
|
|
template<typename Container>
|
|
|
|
struct static_size_or_zero<
|
|
|
|
Container,
|
|
|
|
typename std::enable_if<!sprout::is_fixed_container<sprout::container_traits<Container> >::value>::type
|
|
|
|
>
|
2013-11-22 12:11:08 +00:00
|
|
|
: public sprout::integral_constant<
|
2013-01-13 16:13:48 +00:00
|
|
|
typename sprout::container_traits<Container>::size_type,
|
|
|
|
0
|
|
|
|
>
|
|
|
|
{};
|
|
|
|
} // namespace sprout
|
2012-03-31 07:24:13 +00:00
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
|