2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2016-02-25 09:48:28 +00:00
|
|
|
Copyright (c) 2011-2016 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
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)
|
|
|
|
=============================================================================*/
|
2012-03-31 07:24:13 +00:00
|
|
|
#ifndef SPROUT_CONTAINER_END_HPP
|
|
|
|
#define SPROUT_CONTAINER_END_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
2014-04-30 07:30:26 +00:00
|
|
|
#include <sprout/workaround/std/cstddef.hpp>
|
2014-07-12 03:59:16 +00:00
|
|
|
#include <sprout/container/traits_fwd.hpp>
|
2012-03-31 07:24:13 +00:00
|
|
|
#include <sprout/container/container_traits.hpp>
|
2012-09-29 08:10:46 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
2012-03-31 07:24:13 +00:00
|
|
|
//
|
|
|
|
// end
|
|
|
|
//
|
2013-04-22 14:55:30 +00:00
|
|
|
// effect:
|
2016-04-10 04:48:41 +00:00
|
|
|
// sprout::container_range_traits<Container>::range_end(cont)
|
2013-04-22 14:55:30 +00:00
|
|
|
// [default]
|
2016-04-10 04:48:41 +00:00
|
|
|
// ADL callable range_end(cont) -> range_end(cont)
|
|
|
|
// [default]
|
2016-04-14 16:47:14 +00:00
|
|
|
// Container is T[N] -> iterator(cont)
|
2016-04-17 07:11:43 +00:00
|
|
|
// otherwise, Container is not const
|
|
|
|
// && sprout::is_const_iterator_cast_convertible<const_iterator, iterator>
|
|
|
|
// && (callable sprout::as_const(cont).end()
|
|
|
|
// || ADL(without sprout) callable end(sprout::as_const(cont))
|
|
|
|
// )
|
|
|
|
// -> sprout::const_iterator_cast<iterator>(sprout::end(sprout::as_const(cont)))
|
|
|
|
// otherwise, callable cont.end() -> cont.end()
|
|
|
|
// otherwise, ADL(without sprout) callable end(cont) -> end(cont)
|
2016-04-14 16:47:14 +00:00
|
|
|
// otherwise -> std::end(cont)
|
2013-04-22 14:55:30 +00:00
|
|
|
//
|
2012-03-31 07:24:13 +00:00
|
|
|
template<typename Container>
|
2013-04-22 04:04:27 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
2012-07-21 03:12:11 +00:00
|
|
|
end(Container& cont) {
|
2016-04-10 04:48:41 +00:00
|
|
|
return sprout::container_range_traits<Container>::range_end(cont);
|
2012-09-29 08:10:46 +00:00
|
|
|
}
|
|
|
|
template<typename Container>
|
2013-04-22 04:04:27 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
2012-09-29 08:10:46 +00:00
|
|
|
end(Container const& cont) {
|
2016-04-10 04:48:41 +00:00
|
|
|
return sprout::container_range_traits<Container const>::range_end(cont);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
template<typename T, std::size_t N>
|
2013-04-22 04:04:27 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
2012-07-21 03:12:11 +00:00
|
|
|
end(T (& arr)[N]) {
|
2016-04-10 04:48:41 +00:00
|
|
|
return sprout::container_range_traits<T[N]>::range_end(arr);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
template<typename T, std::size_t N>
|
2013-04-22 04:04:27 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
2012-07-21 03:12:11 +00:00
|
|
|
end(T const (& arr)[N]) {
|
2016-04-10 04:48:41 +00:00
|
|
|
return sprout::container_range_traits<T const[N]>::range_end(arr);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// cend
|
|
|
|
//
|
|
|
|
template<typename Container>
|
2013-04-22 04:04:27 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
2012-07-21 03:12:11 +00:00
|
|
|
cend(Container const& cont) {
|
2013-04-22 14:55:30 +00:00
|
|
|
return sprout::end(cont);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
template<typename T, std::size_t N>
|
2013-04-22 04:04:27 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
2012-07-21 03:12:11 +00:00
|
|
|
cend(T const (& arr)[N]) {
|
2013-04-22 14:55:30 +00:00
|
|
|
return sprout::end(arr);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
2014-07-12 03:59:16 +00:00
|
|
|
#include <sprout/container/container_range_traits.hpp>
|
|
|
|
|
2012-03-31 07:24:13 +00:00
|
|
|
#endif // #ifndef SPROUT_CONTAINER_END_HPP
|