2012-12-22 11:10:27 +00:00
|
|
|
#ifndef SPROUT_RANGE_PTR_RANGE_HPP
|
|
|
|
#define SPROUT_RANGE_PTR_RANGE_HPP
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <iterator>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#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>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::range::range_container<sprout::ptr_index_iterator<T> >
|
|
|
|
make_ptr_range(T* p, typename std::iterator_traits<T*>::difference_type n) {
|
|
|
|
return sprout::range::range_container<sprout::ptr_index_iterator<T> >(
|
|
|
|
sprout::ptr_index_iterator<T>(p),
|
|
|
|
sprout::ptr_index_iterator<T>(p, n)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-12-23 12:48:18 +00:00
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::range::range_container<sprout::ptr_index_iterator<T> >
|
|
|
|
make_ptr_range(T* first, T* last) {
|
|
|
|
return sprout::range::range_container<sprout::ptr_index_iterator<T> >(
|
|
|
|
sprout::ptr_index_iterator<T>(first),
|
2013-01-03 08:01:50 +00:00
|
|
|
sprout::ptr_index_iterator<T>(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>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::range::range_container<sprout::ptr_index_iterator<T> >
|
|
|
|
make_ptr_range(T (& arr)[N]) {
|
|
|
|
return sprout::range::range_container<sprout::ptr_index_iterator<T> >(
|
|
|
|
sprout::ptr_index_iterator<T>(arr),
|
|
|
|
sprout::ptr_index_iterator<T>(arr, N)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace range
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_RANGE_PTR_RANGE_HPP
|