/*============================================================================= Copyright (c) 2011-2017 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_DETAIL_RANGE_SIZE_HPP #define SPROUT_CONTAINER_DETAIL_RANGE_SIZE_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout_adl { sprout::not_found_via_adl range_size(...); } // namespace sprout_adl namespace sprout { namespace detail { 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)); } } // namespace detail } // namespace sprout namespace sprout_container_range_detail { template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type range_size(Container const& cont) { return sprout::detail::range_size_impl(cont); } } // namespace sprout_container_range_detail #endif // #ifndef SPROUT_CONTAINER_DETAIL_RANGE_SIZE_HPP