Sprout/sprout/container/end.hpp

87 lines
2.9 KiB
C++
Raw Normal View History

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)
=============================================================================*/
#ifndef SPROUT_CONTAINER_END_HPP
#define SPROUT_CONTAINER_END_HPP
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/container/traits_fwd.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/adl/not_found.hpp>
namespace sprout_adl {
2012-09-29 14:39:00 +00:00
sprout::not_found_via_adl range_end(...);
} // namespace sprout_adl
namespace sprout {
namespace container_detail {
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
range_end(Container& cont) {
return sprout::container_range_traits<Container>::range_end(cont);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
range_end(Container const& cont) {
return sprout::container_range_traits<Container>::range_end(cont);
}
} // namespace container_detail
//
// end
//
2013-04-22 14:55:30 +00:00
// effect:
// ADL callable range_end(cont) -> range_end(cont)
// otherwise -> sprout::container_range_traits<Container>::range_end(cont)
// [default]
// cont.end()
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
2012-07-21 03:12:11 +00:00
end(Container& cont) {
using sprout::container_detail::range_end;
using sprout_adl::range_end;
return range_end(cont);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
end(Container const& cont) {
using sprout::container_detail::range_end;
using sprout_adl::range_end;
return range_end(cont);
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
2012-07-21 03:12:11 +00:00
end(T (& arr)[N]) {
return sprout::container_detail::range_end(arr);
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
2012-07-21 03:12:11 +00:00
end(T const (& arr)[N]) {
return sprout::container_detail::range_end(arr);
}
//
// cend
//
template<typename Container>
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);
}
template<typename T, std::size_t N>
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);
}
} // namespace sprout
#include <sprout/container/container_range_traits.hpp>
#endif // #ifndef SPROUT_CONTAINER_END_HPP