#ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP #define SPROUT_CONTAINER_CONTAINER_TRAITS_HPP #include #include #include #include #include #include namespace sprout { template struct container_traits; namespace detail { // // 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 // 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); // // has_static_size // SPROUT_HAS_XXX_VALUE_DEF_LAZY(static_size); template struct inherit_if_fixed_size {}; template struct inherit_if_fixed_size< Container, typename std::enable_if::value>::type > { public: static SPROUT_CONSTEXPR decltype(Container::static_size) fixed_size() { return Container::static_size; } }; template struct container_traits_default : public sprout::detail::inherit_if_value_type , public sprout::detail::inherit_if_iterator , public sprout::detail::inherit_if_const_iterator , public sprout::detail::inherit_if_reference , public sprout::detail::inherit_if_const_reference , public sprout::detail::inherit_if_size_type , public sprout::detail::inherit_if_difference_type , public sprout::detail::inherit_if_pointer , public sprout::detail::inherit_if_const_pointer , public sprout::detail::inherit_if_static_size , public sprout::detail::inherit_if_fixed_size {}; template struct container_traits_default { public: typedef T value_type; typedef T* iterator; typedef T const* const_iterator; 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: SPROUT_STATIC_CONSTEXPR size_type static_size = N ; public: static SPROUT_CONSTEXPR size_type fixed_size() { return static_size; } }; } // namespace detail // // container_traits // template struct container_traits : public sprout::detail::container_traits_default {}; template struct container_traits : public sprout::container_traits { public: typedef typename sprout::container_traits::const_iterator iterator; typedef typename sprout::container_traits::const_reference reference; typedef typename sprout::container_traits::const_pointer pointer; }; template struct container_traits : public sprout::detail::container_traits_default {}; template struct container_traits : public sprout::container_traits { public: typedef typename sprout::container_traits::const_iterator iterator; typedef typename sprout::container_traits::const_reference reference; typedef typename sprout::container_traits::const_pointer pointer; }; } // namespace sprout #endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP