/*============================================================================= Copyright (c) 2011-2019 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_INDEX_OF_HPP #define SPROUT_CONTAINER_INDEX_OF_HPP #include #include #include #include namespace sprout { // // index_of // // effect: // sprout::container_range_traits::range_index_of(cont, p) // [default] // ADL callable range_index_of(cont, p) -> range_index_of(cont, p) // [default] // Container is T[N] -> p - iterator(cont) // otherwise, Container is not const // && sprout::is_const_iterator_cast_convertible // && (callable sprout::as_const(cont).index_of(p) // || callable sprout::as_const(cont).begin() // || ADL(without sprout) callable begin(sprout::as_const(cont)) // ) // -> sprout::index_of(sprout::as_const(cont), sprout::const_iterator_cast(p)) // otherwise, callable cont.index_of(p) -> cont.index_of(p) // otherwise -> sprout::distance(sprout::begin(cont), p) // template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type index_of(Container& cont, typename sprout::container_traits::iterator p) { return sprout::container_range_traits::range_index_of(cont, p); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type index_of(Container const& cont, typename sprout::container_traits::iterator p) { return sprout::container_range_traits::range_index_of(cont, p); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type index_of(T (& arr)[N], typename sprout::container_traits::iterator p) { return sprout::container_range_traits::range_index_of(arr, p); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type index_of(T const (& arr)[N], typename sprout::container_traits::iterator p) { return sprout::container_range_traits::range_index_of(arr, p); } // // cindex_of // template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type cindex_of(Container const& cont, typename sprout::container_traits::iterator p) { return sprout::index_of(cont, p); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::size_type cindex_of(T const (& arr)[N], typename sprout::container_traits::iterator p) { return sprout::index_of(arr, p); } } // namespace sprout #include #endif // #ifndef SPROUT_CONTAINER_INDEX_OF_HPP