/*============================================================================= 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_DATA_HPP #define SPROUT_CONTAINER_DETAIL_RANGE_DATA_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout_adl { sprout::not_found_via_adl range_data(...); } // namespace sprout_adl namespace sprout { namespace detail { template struct has_mem_data_test { public: template< typename U = T, typename = typename sprout::identity().data())>::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_data : public Base_ {}; #else template struct has_mem_data : public sprout::identity::test(0))>::type {}; #endif template struct is_substitutable_const_data : public sprout::bool_constant< sprout::is_const_cast_convertible< typename sprout::container_traits::pointer, typename sprout::container_traits::pointer >::value && sprout::detail::has_mem_data::value > {}; template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::is_substitutable_const_data::value, typename sprout::container_traits::pointer >::type range_data_impl(Container& cont) { typedef typename sprout::container_traits::pointer type; return const_cast(sprout::data(sprout::as_const(cont))); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::is_substitutable_const_data::value, typename sprout::container_traits::pointer >::type range_data_impl(Container& cont) { return cont.data(); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data_impl(Container const& cont) { return cont.data(); } } // namespace detail } // namespace sprout namespace sprout_container_range_detail { template inline SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(Container& cont) { return sprout::detail::range_data_impl(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::pointer range_data(Container const& cont) { return sprout::detail::range_data_impl(cont); } } // namespace sprout_container_range_detail #endif // #ifndef SPROUT_CONTAINER_DETAIL_RANGE_DATA_HPP