/*============================================================================= 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_FRONT_HPP #define SPROUT_CONTAINER_FRONT_HPP #include #include #include #include namespace sprout { // // front // // effect: // sprout::container_range_traits::range_front(cont) // [default] // ADL callable range_front(cont) -> range_front(cont) // [default] // Container is T[N] -> cont[0] // otherwise, Container is not const // && sprout::is_const_reference_cast_convertible // && (callable sprout::as_const(cont).front() // || callable sprout::as_const(cont).begin() // || ADL(without sprout) callable begin(sprout::as_const(cont)) // ) // -> sprout::const_reference_cast(sprout::front(sprout::as_const(cont))) // otherwise, callable cont.front() -> cont.front() // otherwise -> *sprout::begin(cont) // template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference front(Container& cont) { return sprout::container_range_traits::range_front(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference front(Container const& cont) { return sprout::container_range_traits::range_front(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference front(T (& arr)[N]) { return sprout::container_range_traits::range_front(arr); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference front(T const (& arr)[N]) { return sprout::container_range_traits::range_front(arr); } // // cfront // template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference cfront(Container const& cont) { return sprout::front(cont); } template inline SPROUT_CONSTEXPR typename sprout::container_traits::reference cfront(T const (& arr)[N]) { return sprout::front(arr); } } // namespace sprout #include #endif // #ifndef SPROUT_CONTAINER_FRONT_HPP