diff --git a/sprout/container/container_range_traits.hpp b/sprout/container/container_range_traits.hpp index e062f9c7..96511ef5 100644 --- a/sprout/container/container_range_traits.hpp +++ b/sprout/container/container_range_traits.hpp @@ -335,93 +335,111 @@ namespace sprout { return *sprout::next(sprout::begin(cont), i); } }; + + // + // container_range_traits_default + // + template + struct container_range_traits_default + : public sprout::detail::container_range_traits_range_size_impl + , public sprout::detail::container_range_traits_range_empty_impl + , public sprout::detail::container_range_traits_range_front_impl + , public sprout::detail::container_range_traits_range_front_const_impl + , public sprout::detail::container_range_traits_range_back_impl + , public sprout::detail::container_range_traits_range_back_const_impl + , public sprout::detail::container_range_traits_range_at_impl + , public sprout::detail::container_range_traits_range_at_const_impl + { + using sprout::detail::container_range_traits_range_front_impl::range_front; + using sprout::detail::container_range_traits_range_front_const_impl::range_front; + using sprout::detail::container_range_traits_range_back_impl::range_back; + using sprout::detail::container_range_traits_range_back_const_impl::range_back; + using sprout::detail::container_range_traits_range_at_impl::range_at; + using sprout::detail::container_range_traits_range_at_const_impl::range_at; + public: + // iterators: + static SPROUT_CONSTEXPR typename sprout::container_traits::iterator + range_begin(Container& cont) { + return cont.begin(); + } + static SPROUT_CONSTEXPR typename sprout::container_traits::iterator + range_begin(Container const& cont) { + return cont.begin(); + } + static SPROUT_CONSTEXPR typename sprout::container_traits::iterator + range_end(Container& cont) { + return cont.end(); + } + static SPROUT_CONSTEXPR typename sprout::container_traits::iterator + range_end(Container const& cont) { + return cont.end(); + } + // data access: + static SPROUT_CONSTEXPR typename sprout::container_traits::pointer + range_data(Container& cont) { + return cont.data(); + } + static SPROUT_CONSTEXPR typename sprout::container_traits::pointer + range_data(Container const& cont) { + return cont.data(); + } + }; + // + // container_range_traits_const_default + // + template + struct container_range_traits_const_default { + public: + // iterators: + static SPROUT_CONSTEXPR typename sprout::container_traits::iterator + range_begin(Container const& cont) { + return sprout::container_range_traits::range_begin(cont); + } + static SPROUT_CONSTEXPR typename sprout::container_traits::iterator + range_end(Container const& cont) { + return sprout::container_range_traits::range_end(cont); + } + // capacity: + static SPROUT_CONSTEXPR typename sprout::container_traits::size_type + range_size(Container const& cont) { + return sprout::container_range_traits::range_size(cont); + } + static SPROUT_CONSTEXPR bool + range_empty(Container const& cont) { + return sprout::container_range_traits::range_empty(cont); + } + // element access: + static SPROUT_CONSTEXPR typename sprout::container_traits::reference + range_front(Container const& cont) { + return sprout::container_range_traits::range_front(cont); + } + static SPROUT_CONSTEXPR typename sprout::container_traits::reference + range_back(Container const& cont) { + return sprout::container_range_traits::range_back(cont); + } + static SPROUT_CONSTEXPR typename sprout::container_traits::reference + range_at(Container const& cont, typename sprout::container_traits::size_type i) { + return sprout::container_range_traits::range_at(cont, i); + } + // data access: + static SPROUT_CONSTEXPR typename sprout::container_traits::pointer + range_data(Container const& cont) { + return sprout::container_range_traits::range_data(cont); + } + }; } // namespace detail + // + // container_range_traits + // template struct container_range_traits - : public sprout::detail::container_range_traits_range_size_impl - , public sprout::detail::container_range_traits_range_empty_impl - , public sprout::detail::container_range_traits_range_front_impl - , public sprout::detail::container_range_traits_range_front_const_impl - , public sprout::detail::container_range_traits_range_back_impl - , public sprout::detail::container_range_traits_range_back_const_impl - , public sprout::detail::container_range_traits_range_at_impl - , public sprout::detail::container_range_traits_range_at_const_impl - { - using sprout::detail::container_range_traits_range_front_impl::range_front; - using sprout::detail::container_range_traits_range_front_const_impl::range_front; - using sprout::detail::container_range_traits_range_back_impl::range_back; - using sprout::detail::container_range_traits_range_back_const_impl::range_back; - using sprout::detail::container_range_traits_range_at_impl::range_at; - using sprout::detail::container_range_traits_range_at_const_impl::range_at; - public: - // iterators: - static SPROUT_CONSTEXPR typename sprout::container_traits::iterator - range_begin(Container& cont) { - return cont.begin(); - } - static SPROUT_CONSTEXPR typename sprout::container_traits::iterator - range_begin(Container const& cont) { - return cont.begin(); - } - static SPROUT_CONSTEXPR typename sprout::container_traits::iterator - range_end(Container& cont) { - return cont.end(); - } - static SPROUT_CONSTEXPR typename sprout::container_traits::iterator - range_end(Container const& cont) { - return cont.end(); - } - // data access: - static SPROUT_CONSTEXPR typename sprout::container_traits::pointer - range_data(Container& cont) { - return cont.data(); - } - static SPROUT_CONSTEXPR typename sprout::container_traits::pointer - range_data(Container const& cont) { - return cont.data(); - } - }; + : public sprout::detail::container_range_traits_default + {}; template - struct container_range_traits { - public: - // iterators: - static SPROUT_CONSTEXPR typename sprout::container_traits::iterator - range_begin(Container const& cont) { - return sprout::container_range_traits::range_begin(cont); - } - static SPROUT_CONSTEXPR typename sprout::container_traits::iterator - range_end(Container const& cont) { - return sprout::container_range_traits::range_end(cont); - } - // capacity: - static SPROUT_CONSTEXPR typename sprout::container_traits::size_type - range_size(Container const& cont) { - return sprout::container_range_traits::range_size(cont); - } - static SPROUT_CONSTEXPR bool - range_empty(Container const& cont) { - return sprout::container_range_traits::range_empty(cont); - } - // element access: - static SPROUT_CONSTEXPR typename sprout::container_traits::reference - range_front(Container const& cont) { - return sprout::container_range_traits::range_front(cont); - } - static SPROUT_CONSTEXPR typename sprout::container_traits::reference - range_back(Container const& cont) { - return sprout::container_range_traits::range_back(cont); - } - static SPROUT_CONSTEXPR typename sprout::container_traits::reference - range_at(Container const& cont, typename sprout::container_traits::size_type i) { - return sprout::container_range_traits::range_at(cont, i); - } - // data access: - static SPROUT_CONSTEXPR typename sprout::container_traits::pointer - range_data(Container const& cont) { - return sprout::container_range_traits::range_data(cont); - } - }; + struct container_range_traits + : public sprout::detail::container_range_traits_const_default + {}; template struct container_range_traits { diff --git a/sprout/container/std/array.hpp b/sprout/container/std/array.hpp index f9827c70..62b56995 100644 --- a/sprout/container/std/array.hpp +++ b/sprout/container/std/array.hpp @@ -35,7 +35,9 @@ namespace sprout { // container_range_traits // template - struct container_range_traits > { + struct container_range_traits > + : public sprout::detail::container_range_traits_default > + { public: static SPROUT_CONSTEXPR typename sprout::container_traits >::iterator range_begin(std::array& cont) {