/*============================================================================= Copyright (c) 2011-2016 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) =============================================================================*/ #ifndef SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP #define SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout_adl { sprout::not_found_via_adl begin(...); sprout::not_found_via_adl end(...); sprout::not_found_via_adl range_begin(...); sprout::not_found_via_adl range_end(...); sprout::not_found_via_adl range_size(...); sprout::not_found_via_adl range_empty(...); sprout::not_found_via_adl range_front(...); sprout::not_found_via_adl range_back(...); sprout::not_found_via_adl range_at(...); sprout::not_found_via_adl range_nth(...); sprout::not_found_via_adl range_index_of(...); sprout::not_found_via_adl range_data(...); } // namespace sprout_adl namespace sprout_container_range_detail { using sprout_adl::begin; using sprout_adl::end; template struct has_adl_begin_test { public: template< typename U = T, typename R = typename sprout::identity()))>::type > static sprout::is_found_via_adl test(int); static sprout::false_type test(...); }; template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_adl_begin(Container& cont) { return begin(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_adl_begin(Container const& cont) { return begin(cont); } template struct has_adl_end_test { public: template< typename U = T, typename R = typename sprout::identity()))>::type > static sprout::is_found_via_adl test(int); static sprout::false_type test(...); }; template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_adl_end(Container& cont) { return end(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_adl_end(Container const& cont) { return end(cont); } } // namespace sprout_container_range_detail namespace sprout { namespace detail { #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_adl_begin : public Base_ {}; #else template struct has_adl_begin : public sprout::identity::test(0))>::type {}; #endif template::value> struct has_adl_begin_without_sprout : public sprout::false_type {}; template struct has_adl_begin_without_sprout : public sprout::detail::has_adl_begin {}; template struct has_mem_begin_test { public: template< typename U = T, typename = typename sprout::identity().begin())>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_begin : public Base_ {}; #else template struct has_mem_begin : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_adl_begin(Container& cont) { using std::begin; return begin(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_adl_begin(Container const& cont) { using std::begin; return begin(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_adl_begin_without_sprout::value, typename sprout::container_traits::iterator >::type range_begin_impl(Container& cont) { return sprout_container_range_detail::range_adl_begin(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_adl_begin_without_sprout::value && sprout::detail::has_mem_begin::value, typename sprout::container_traits::iterator >::type range_begin_impl(Container& cont) { return cont.begin(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_adl_begin_without_sprout::value && !sprout::detail::has_mem_begin::value, typename sprout::container_traits::iterator >::type range_begin_impl(Container& cont) { return std::begin(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_adl_begin_without_sprout::value, typename sprout::container_traits::iterator >::type range_begin_impl(Container const& cont) { return sprout_container_range_detail::range_adl_begin(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_adl_begin_without_sprout::value && sprout::detail::has_mem_begin::value, typename sprout::container_traits::iterator >::type range_begin_impl(Container const& cont) { return cont.begin(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_adl_begin_without_sprout::value && !sprout::detail::has_mem_begin::value, typename sprout::container_traits::iterator >::type range_begin_impl(Container const& cont) { return std::begin(cont); } #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_adl_end : public Base_ {}; #else template struct has_adl_end : public sprout::identity::test(0))>::type {}; #endif template::value> struct has_adl_end_without_sprout : public sprout::false_type {}; template struct has_adl_end_without_sprout : public sprout::detail::has_adl_end {}; template struct has_mem_end_test { public: template< typename U = T, typename = typename sprout::identity().end())>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_end : public Base_ {}; #else template struct has_mem_end : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_adl_end(Container& cont) { using std::end; return end(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_adl_end(Container const& cont) { using std::end; return end(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_adl_end_without_sprout::value, typename sprout::container_traits::iterator >::type range_end_impl(Container& cont) { return sprout_container_range_detail::range_adl_end(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_adl_end_without_sprout::value && sprout::detail::has_mem_end::value, typename sprout::container_traits::iterator >::type range_end_impl(Container& cont) { return cont.end(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_adl_end_without_sprout::value && !sprout::detail::has_mem_end::value, typename sprout::container_traits::iterator >::type range_end_impl(Container& cont) { return std::end(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_adl_end_without_sprout::value, typename sprout::container_traits::iterator >::type range_end_impl(Container const& cont) { return sprout_container_range_detail::range_adl_end(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_adl_end_without_sprout::value && sprout::detail::has_mem_end::value, typename sprout::container_traits::iterator >::type range_end_impl(Container const& cont) { return cont.end(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_adl_end_without_sprout::value && !sprout::detail::has_mem_end::value, typename sprout::container_traits::iterator >::type range_end_impl(Container const& cont) { return std::end(cont); } template struct has_mem_size_test { public: template< typename U = T, typename = typename sprout::identity().size())>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_size : public Base_ {}; #else template struct has_mem_size : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_size::value, typename sprout::container_traits::size_type >::type range_size_impl(Container const& cont) { return cont.size(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_size::value, typename sprout::container_traits::size_type >::type range_size_impl(Container const& cont) { return sprout::distance(sprout::begin(cont), sprout::end(cont)); } template struct has_mem_empty_test { public: template< typename U = T, typename = typename sprout::identity().empty())>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_empty : public Base_ {}; #else template struct has_mem_empty : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_empty::value, bool >::type range_empty_impl(Container const& cont) { return cont.empty(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_empty::value, bool >::type range_empty_impl(Container const& cont) { return sprout::size(cont) == 0; } template struct has_mem_front_test { public: template< typename U = T, typename = typename sprout::identity().front())>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_front : public Base_ {}; #else template struct has_mem_front : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_front::value, typename sprout::container_traits::reference >::type range_front_impl(Container& cont) { return cont.front(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_front::value, typename sprout::container_traits::reference >::type range_front_impl(Container& cont) { return *sprout::begin(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_front::value, typename sprout::container_traits::reference >::type range_front_impl(Container const& cont) { return cont.front(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_front::value, typename sprout::container_traits::reference >::type range_front_impl(Container const& cont) { return *sprout::begin(cont); } template struct has_mem_back_test { public: template< typename U = T, typename = typename sprout::identity().back())>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_back : public Base_ {}; #else template struct has_mem_back : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_back::value, typename sprout::container_traits::reference >::type range_back_impl(Container& cont) { return cont.back(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_back::value, typename sprout::container_traits::reference >::type range_back_impl(Container& cont) { return *sprout::begin(cont); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_back::value, typename sprout::container_traits::reference >::type range_back_impl(Container const& cont) { return cont.back(); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_back::value, typename sprout::container_traits::reference >::type range_back_impl(Container const& cont) { return *sprout::next(sprout::begin(cont), sprout::size(cont) - 1); } template struct has_mem_at_test { public: template< typename U = T, typename = typename sprout::identity().at(std::declval::size_type>()))>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_at : public Base_ {}; #else template struct has_mem_at : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_at::value, typename sprout::container_traits::reference >::type range_at_impl(Container& cont, typename sprout::container_traits::size_type i) { return cont.at(i); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_at::value, typename sprout::container_traits::reference >::type range_at_impl(Container& cont, typename sprout::container_traits::size_type i) { return *sprout::next(sprout::begin(cont), i); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_at::value, typename sprout::container_traits::reference >::type range_at_impl(Container const& cont, typename sprout::container_traits::size_type i) { return cont.at(i); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_at::value, typename sprout::container_traits::reference >::type range_at_impl(Container const& cont, typename sprout::container_traits::size_type i) { return *sprout::next(sprout::begin(cont), i); } template struct has_mem_nth_test { public: template< typename U = T, typename = typename sprout::identity().nth(std::declval::size_type>()))>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_nth : public Base_ {}; #else template struct has_mem_nth : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_nth::value, typename sprout::container_traits::iterator >::type range_nth_impl(Container& cont, typename sprout::container_traits::size_type i) { return cont.nth(i); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_nth::value, typename sprout::container_traits::iterator >::type range_nth_impl(Container& cont, typename sprout::container_traits::size_type i) { return sprout::next(sprout::begin(cont), i); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_nth::value, typename sprout::container_traits::iterator >::type range_nth_impl(Container const& cont, typename sprout::container_traits::size_type i) { return cont.nth(i); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_nth::value, typename sprout::container_traits::iterator >::type range_nth_impl(Container const& cont, typename sprout::container_traits::size_type i) { return sprout::next(sprout::begin(cont), i); } template struct has_mem_index_of_test { public: template< typename U = T, typename = typename sprout::identity().index_of(std::declval::iterator>()))>::type > static sprout::true_type test(int); static sprout::false_type test(...); }; #if defined(_MSC_VER) && (_MSC_VER > 1900) template::test(0))>::type> struct has_mem_index_of : public Base_ {}; #else template struct has_mem_index_of : public sprout::identity::test(0))>::type {}; #endif template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_index_of::value, typename sprout::container_traits::size_type >::type range_index_of_impl(Container& cont, typename sprout::container_traits::iterator p) { return cont.index_of(p); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_index_of::value, typename sprout::container_traits::size_type >::type range_index_of_impl(Container& cont, typename sprout::container_traits::iterator p) { return sprout::distance(begin(cont), p); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::has_mem_index_of::value, typename sprout::container_traits::size_type >::type range_index_of_impl(Container const& cont, typename sprout::container_traits::iterator p) { return cont.index_of(p); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::has_mem_index_of::value, typename sprout::container_traits::size_type >::type range_index_of_impl(Container const& cont, typename sprout::container_traits::iterator p) { return sprout::distance(begin(cont), p); } } // namespace detail } // namespace sprout namespace sprout_container_range_detail { template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_begin(Container& cont) { return sprout::detail::range_begin_impl(cont); // return cont.begin(); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_begin(Container const& cont) { return sprout::detail::range_begin_impl(cont); // return cont.begin(); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_end(Container& cont) { return cont.end(); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_end(Container const& cont) { return cont.end(); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_size(Container const& cont) { return sprout::detail::range_size_impl(cont); } template inline SPROUT_CONSTEXPR bool range_empty(Container const& cont) { return sprout::detail::range_empty_impl(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference range_front(Container& cont) { return sprout::detail::range_front_impl(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference range_front(Container const& cont) { return sprout::detail::range_front_impl(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference range_back(Container& cont) { return sprout::detail::range_back_impl(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference range_back(Container const& cont) { return sprout::detail::range_back_impl(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference range_at(Container& cont, typename sprout::container_traits::size_type i) { return sprout::detail::range_at_impl(cont, i); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference range_at(Container const& cont, typename sprout::container_traits::size_type i) { return sprout::detail::range_at_impl(cont, i); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_nth(Container& cont, typename sprout::container_traits::size_type i) { return sprout::detail::range_nth_impl(cont, i); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_nth(Container const& cont, typename sprout::container_traits::size_type i) { return sprout::detail::range_nth_impl(cont, i); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_index_of(Container& cont, typename sprout::container_traits::iterator p) { return sprout::detail::range_index_of_impl(cont, p); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_index_of(Container const& cont, typename sprout::container_traits::iterator p) { return sprout::detail::range_index_of_impl(cont, p); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(Container& cont) { return cont.data(); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(Container const& cont) { return cont.data(); } } // namespace sprout_container_range_detail namespace sprout { namespace detail { // // container_range_traits_default // template struct container_range_traits_default { public: // iterators: static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_begin(Container& cont) { using sprout_container_range_detail::range_begin; using sprout_adl::range_begin; return range_begin(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_begin(Container const& cont) { using sprout_container_range_detail::range_begin; using sprout_adl::range_begin; return range_begin(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_end(Container& cont) { using sprout_container_range_detail::range_end; using sprout_adl::range_end; return range_end(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_end(Container const& cont) { using sprout_container_range_detail::range_end; using sprout_adl::range_end; return range_end(cont); } // capacity: static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_size(Container const& cont) { using sprout_container_range_detail::range_size; using sprout_adl::range_size; return range_size(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_empty(Container const& cont) { using sprout_container_range_detail::range_empty; using sprout_adl::range_empty; return range_empty(cont); } // element access: static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_front(Container& cont) { using sprout_container_range_detail::range_front; using sprout_adl::range_front; return range_front(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_front(Container const& cont) { using sprout_container_range_detail::range_front; using sprout_adl::range_front; return range_front(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_back(Container& cont) { using sprout_container_range_detail::range_back; using sprout_adl::range_back; return range_back(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_back(Container const& cont) { using sprout_container_range_detail::range_back; using sprout_adl::range_back; return range_back(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_at(Container& cont, typename sprout::container_traits::size_type i) { using sprout_container_range_detail::range_at; using sprout_adl::range_at; return range_at(cont, i); } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_at(Container const& cont, typename sprout::container_traits::size_type i) { using sprout_container_range_detail::range_at; using sprout_adl::range_at; return range_at(cont, i); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_nth(Container& cont, typename sprout::container_traits::size_type i) { using sprout_container_range_detail::range_nth; using sprout_adl::range_nth; return range_nth(cont, i); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_nth(Container const& cont, typename sprout::container_traits::size_type i) { using sprout_container_range_detail::range_nth; using sprout_adl::range_nth; return range_nth(cont, i); } static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_index_of(Container& cont, typename sprout::container_traits::iterator p) { using sprout_container_range_detail::range_index_of; using sprout_adl::range_index_of; return range_index_of(cont, p); } static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_index_of(Container const& cont, typename sprout::container_traits::iterator p) { using sprout_container_range_detail::range_index_of; using sprout_adl::range_index_of; return range_index_of(cont, p); } // data access: static SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(Container& cont) { using sprout_container_range_detail::range_data; using sprout_adl::range_data; return range_data(cont); } static SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(Container const& cont) { using sprout_container_range_detail::range_data; using sprout_adl::range_data; return range_data(cont); } }; // // 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); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_nth(Container const& cont, typename sprout::container_traits::size_type i) { return sprout::container_range_traits::range_nth(cont, i); } static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_index_of(Container const& cont, typename sprout::container_traits::iterator p) { return sprout::container_range_traits::range_index_of(cont, p); } // 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_default {}; template struct container_range_traits : public sprout::detail::container_range_traits_const_default {}; template struct container_range_traits { public: // iterators: static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_begin(T (& arr)[N]) { typedef typename sprout::container_traits::iterator type; return type(arr); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_begin(T const (& arr)[N]) { typedef typename sprout::container_traits::iterator type; return type(arr); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_end(T (& arr)[N]) { typedef typename sprout::container_traits::iterator type; return type(arr) + N; } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_end(T const (& arr)[N]) { typedef typename sprout::container_traits::iterator type; return type(arr) + N; } // capacity: static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_size(T const (&)[N]) { return N; } static SPROUT_CONSTEXPR bool range_empty(T const (&)[N]) { return false; } // element access: static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_front(T (& arr)[N]) { return arr[0]; } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_front(T const (& arr)[N]) { return arr[0]; } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_back(T (& arr)[N]) { return arr[N - 1]; } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_back(T const (& arr)[N]) { return arr[N - 1]; } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_at(T (& arr)[N], typename sprout::container_traits::size_type i) { return arr[i]; } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_at(T const (& arr)[N], typename sprout::container_traits::size_type i) { return arr[i]; } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_nth(T (& arr)[N], typename sprout::container_traits::size_type i) { typedef typename sprout::container_traits::iterator type; return type(arr) + i; } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_nth(T const (& arr)[N], typename sprout::container_traits::size_type i) { typedef typename sprout::container_traits::iterator type; return type(arr) + i; } static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_index_of(T (& arr)[N], typename sprout::container_traits::iterator p) { typedef typename sprout::container_traits::iterator type; return sprout::distance(type(arr), p); } static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_index_of(T const (& arr)[N], typename sprout::container_traits::iterator p) { typedef typename sprout::container_traits::iterator type; return sprout::distance(type(arr), p); } // data access: static SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(T (& arr)[N]) { typedef typename sprout::container_traits::pointer type; return type(arr); } static SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(T const (& arr)[N]) { typedef typename sprout::container_traits::pointer type; return type(arr); } }; template struct container_range_traits { public: // iterators: static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_begin(T const (& arr)[N]) { return sprout::container_range_traits::range_begin(arr); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_end(T const (& arr)[N]) { return sprout::container_range_traits::range_end(arr); } // capacity: static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_size(T const (& arr)[N]) { return sprout::container_range_traits::range_size(arr); } static SPROUT_CONSTEXPR bool range_empty(T const (& arr)[N]) { return sprout::container_range_traits::range_empty(arr); } // element access: static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_front(T const (& arr)[N]) { return sprout::container_range_traits::range_front(arr); } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_back(T const (& arr)[N]) { return sprout::container_range_traits::range_back(arr); } static SPROUT_CONSTEXPR typename sprout::container_traits::reference range_at(T const (& arr)[N], typename sprout::container_traits::size_type i) { return sprout::container_range_traits::range_at(arr, i); } static SPROUT_CONSTEXPR typename sprout::container_traits::iterator range_nth(T const (& arr)[N], typename sprout::container_traits::size_type i) { return sprout::container_range_traits::range_nth(arr, i); } static SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_index_of(T const (& arr)[N], typename sprout::container_traits::iterator p) { return sprout::container_range_traits::range_index_of(arr, p); } // data access: static SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(T const (& arr)[N]) { return sprout::container_range_traits::range_data(arr); } }; } // namespace sprout #include #include #include #endif // #ifndef SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP