2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2015-01-10 10:13:57 +00:00
|
|
|
Copyright (c) 2011-2015 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_BEGIN_HPP
|
|
|
|
#define SPROUT_CONTAINER_BEGIN_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
|
|
|
#include <sprout/adl/not_found.hpp>
|
|
|
|
|
|
|
|
namespace sprout_adl {
|
2012-09-29 14:39:00 +00:00
|
|
|
sprout::not_found_via_adl range_begin(...);
|
2012-09-29 08:10:46 +00:00
|
|
|
} // namespace sprout_adl
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace container_detail {
|
|
|
|
template<typename Container>
|
2013-04-22 04:04:27 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
2012-09-29 08:10:46 +00:00
|
|
|
range_begin(Container& cont) {
|
2013-04-22 04:04:27 +00:00
|
|
|
return sprout::container_range_traits<Container>::range_begin(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
|
|
|
range_begin(Container const& cont) {
|
2013-04-22 04:04:27 +00:00
|
|
|
return sprout::container_range_traits<Container>::range_begin(cont);
|
2012-12-21 13:35:48 +00:00
|
|
|
}
|
2012-09-29 08:10:46 +00:00
|
|
|
} // namespace container_detail
|
2012-03-31 07:24:13 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// begin
|
|
|
|
//
|
2013-04-22 14:55:30 +00:00
|
|
|
// effect:
|
|
|
|
// ADL callable range_begin(cont) -> range_begin(cont)
|
|
|
|
// otherwise -> sprout::container_range_traits<Container>::range_begin(cont)
|
|
|
|
// [default]
|
|
|
|
// cont.begin()
|
|
|
|
//
|
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
|
|
|
begin(Container& cont) {
|
2012-09-29 08:10:46 +00:00
|
|
|
using sprout::container_detail::range_begin;
|
|
|
|
using sprout_adl::range_begin;
|
|
|
|
return range_begin(cont);
|
|
|
|
}
|
|
|
|
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
|
|
|
begin(Container const& cont) {
|
|
|
|
using sprout::container_detail::range_begin;
|
|
|
|
using sprout_adl::range_begin;
|
|
|
|
return range_begin(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
|
|
|
begin(T (& arr)[N]) {
|
2012-12-21 13:35:48 +00:00
|
|
|
return sprout::container_detail::range_begin(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
|
|
|
begin(T const (& arr)[N]) {
|
2012-12-21 13:35:48 +00:00
|
|
|
return sprout::container_detail::range_begin(arr);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// cbegin
|
|
|
|
//
|
|
|
|
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
|
|
|
cbegin(Container const& cont) {
|
2013-04-22 14:55:30 +00:00
|
|
|
return sprout::begin(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
|
|
|
cbegin(T const (& arr)[N]) {
|
2013-04-22 14:55:30 +00:00
|
|
|
return sprout::begin(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_BEGIN_HPP
|