2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2014-01-08 07:48:12 +00:00
|
|
|
Copyright (c) 2011-2014 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-12-22 11:10:27 +00:00
|
|
|
#ifndef SPROUT_RANGE_PTR_RANGE_HPP
|
|
|
|
#define SPROUT_RANGE_PTR_RANGE_HPP
|
|
|
|
|
|
|
|
#include <iterator>
|
|
|
|
#include <sprout/config.hpp>
|
2014-04-30 07:30:26 +00:00
|
|
|
#include <sprout/workaround/std/cstddef.hpp>
|
2012-12-22 11:10:27 +00:00
|
|
|
#include <sprout/iterator/ptr_index_iterator.hpp>
|
|
|
|
#include <sprout/range/range_container.hpp>
|
2013-01-03 08:01:50 +00:00
|
|
|
#include <sprout/iterator/operation.hpp>
|
2012-12-22 11:10:27 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace range {
|
|
|
|
//
|
|
|
|
// make_ptr_range
|
|
|
|
//
|
|
|
|
template<typename T>
|
2013-02-18 17:49:10 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::range::range_container<sprout::ptr_index_iterator<T, true> >
|
2012-12-22 11:10:27 +00:00
|
|
|
make_ptr_range(T* p, typename std::iterator_traits<T*>::difference_type n) {
|
2013-02-18 17:49:10 +00:00
|
|
|
return sprout::range::range_container<sprout::ptr_index_iterator<T, true> >(
|
|
|
|
sprout::ptr_index_iterator<T, true>(p),
|
|
|
|
sprout::ptr_index_iterator<T, true>(p, n)
|
2012-12-22 11:10:27 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-12-23 12:48:18 +00:00
|
|
|
template<typename T>
|
2013-02-18 17:49:10 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::range::range_container<sprout::ptr_index_iterator<T, true> >
|
2012-12-23 12:48:18 +00:00
|
|
|
make_ptr_range(T* first, T* last) {
|
2013-02-18 17:49:10 +00:00
|
|
|
return sprout::range::range_container<sprout::ptr_index_iterator<T, true> >(
|
|
|
|
sprout::ptr_index_iterator<T, true>(first),
|
|
|
|
sprout::ptr_index_iterator<T, true>(first, sprout::distance(first, last))
|
2012-12-23 12:48:18 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-12-22 11:10:27 +00:00
|
|
|
template<typename T, std::size_t N>
|
2013-02-18 17:49:10 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::range::range_container<sprout::ptr_index_iterator<T, true> >
|
2012-12-22 11:10:27 +00:00
|
|
|
make_ptr_range(T (& arr)[N]) {
|
2013-02-18 17:49:10 +00:00
|
|
|
return sprout::range::range_container<sprout::ptr_index_iterator<T, true> >(
|
|
|
|
sprout::ptr_index_iterator<T, true>(arr),
|
|
|
|
sprout::ptr_index_iterator<T, true>(arr, N)
|
2012-12-22 11:10:27 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace range
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_RANGE_PTR_RANGE_HPP
|