1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/container/end.hpp

75 lines
2.1 KiB
C++
Raw Normal View History

#ifndef SPROUT_CONTAINER_END_HPP
#define SPROUT_CONTAINER_END_HPP
#include <cstddef>
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/adl/not_found.hpp>
namespace sprout_adl {
sprout::adl_not_found range_end(...);
} // 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();
}
} // namespace container_detail
} // namespace sprout
namespace sprout {
//
// end
//
template<typename Container>
2012-07-21 03:12:11 +00:00
inline typename sprout::container_traits<Container>::iterator
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>
2012-07-21 03:12:11 +00:00
inline typename sprout::container_traits<T[N]>::iterator
end(T (& arr)[N]) {
return arr + N;
}
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]) {
return arr + N;
}
//
// 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) {
using sprout::container_detail::range_end;
using sprout_adl::range_end;
return range_end(cont);
}
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]) {
return arr + N;
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_END_HPP