Sprout/sprout/container/begin.hpp

67 lines
2.3 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_BEGIN_HPP
#define SPROUT_CONTAINER_BEGIN_HPP
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/container/traits_fwd.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
//
// begin
//
2013-04-22 14:55:30 +00:00
// effect:
2016-04-10 04:48:41 +00:00
// sprout::container_range_traits<Container>::range_begin(cont)
2013-04-22 14:55:30 +00:00
// [default]
2016-04-10 04:48:41 +00:00
// ADL callable range_begin(cont) -> range_begin(cont)
// [default]
// Container is T[N] -> iterator(cont)
// otherwise -> cont.begin()
2013-04-22 14:55:30 +00:00
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
2012-07-21 03:12:11 +00:00
begin(Container& cont) {
2016-04-10 04:48:41 +00:00
return sprout::container_range_traits<Container>::range_begin(cont);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
begin(Container const& cont) {
2016-04-10 04:48:41 +00:00
return sprout::container_range_traits<Container const>::range_begin(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
begin(T (& arr)[N]) {
2016-04-10 04:48:41 +00:00
return sprout::container_range_traits<T[N]>::range_begin(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
begin(T const (& arr)[N]) {
2016-04-10 04:48:41 +00:00
return sprout::container_range_traits<T const[N]>::range_begin(arr);
}
//
// cbegin
//
template<typename Container>
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);
}
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
cbegin(T const (& arr)[N]) {
2013-04-22 14:55:30 +00:00
return sprout::begin(arr);
}
} // namespace sprout
#include <sprout/container/container_range_traits.hpp>
#endif // #ifndef SPROUT_CONTAINER_BEGIN_HPP