2012-03-31 07:24:13 +00:00
|
|
|
#ifndef SPROUT_CONTAINER_END_HPP
|
|
|
|
#define SPROUT_CONTAINER_END_HPP
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/container/container_traits.hpp>
|
2012-09-29 08:10:46 +00:00
|
|
|
#include <sprout/adl/not_found.hpp>
|
|
|
|
|
|
|
|
namespace sprout_adl {
|
2012-09-29 14:39:00 +00:00
|
|
|
sprout::not_found_via_adl range_end(...);
|
2012-09-29 08:10:46 +00:00
|
|
|
} // namespace sprout_adl
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace container_detail {
|
|
|
|
template<typename Container>
|
|
|
|
inline typename sprout::container_traits<Container>::iterator
|
|
|
|
range_end(Container& cont) {
|
|
|
|
return cont.end();
|
|
|
|
}
|
|
|
|
template<typename Container>
|
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
|
|
|
range_end(Container const& cont) {
|
|
|
|
return cont.end();
|
|
|
|
}
|
2012-12-21 13:35:48 +00:00
|
|
|
|
|
|
|
template<typename T, std::size_t N>
|
|
|
|
inline typename sprout::container_traits<T[N]>::iterator
|
|
|
|
range_end(T (& arr)[N]) {
|
|
|
|
typedef typename sprout::container_traits<T[N]>::iterator iterator;
|
|
|
|
return iterator(arr) + N;
|
|
|
|
}
|
|
|
|
template<typename T, std::size_t N>
|
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
|
|
|
range_end(T const (& arr)[N]) {
|
|
|
|
typedef typename sprout::container_traits<T const[N]>::const_iterator iterator;
|
|
|
|
return iterator(arr) + N;
|
|
|
|
}
|
2012-09-29 08:10:46 +00:00
|
|
|
} // namespace container_detail
|
|
|
|
} // namespace sprout
|
2012-03-31 07:24:13 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
//
|
|
|
|
// end
|
|
|
|
//
|
|
|
|
template<typename Container>
|
2012-07-21 03:12:11 +00:00
|
|
|
inline typename sprout::container_traits<Container>::iterator
|
|
|
|
end(Container& cont) {
|
2012-09-29 08:10:46 +00:00
|
|
|
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);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
template<typename T, std::size_t N>
|
2012-07-21 03:12:11 +00:00
|
|
|
inline typename sprout::container_traits<T[N]>::iterator
|
|
|
|
end(T (& arr)[N]) {
|
2012-12-21 13:35:48 +00:00
|
|
|
return sprout::container_detail::range_end(arr);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
template<typename T, std::size_t N>
|
2012-07-21 03:12:11 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
|
|
|
end(T const (& arr)[N]) {
|
2012-12-21 13:35:48 +00:00
|
|
|
return sprout::container_detail::range_end(arr);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// cend
|
|
|
|
//
|
|
|
|
template<typename Container>
|
2012-07-21 03:12:11 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
|
|
|
cend(Container const& cont) {
|
2012-09-29 08:10:46 +00:00
|
|
|
using sprout::container_detail::range_end;
|
|
|
|
using sprout_adl::range_end;
|
|
|
|
return range_end(cont);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
template<typename T, std::size_t N>
|
2012-07-21 03:12:11 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
|
|
|
cend(T const (& arr)[N]) {
|
2012-12-21 13:35:48 +00:00
|
|
|
return sprout::container_detail::range_end(arr);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_CONTAINER_END_HPP
|