add make_ptr_range

This commit is contained in:
bolero-MURAKAMI 2012-12-22 20:10:27 +09:00
parent 86cfc72bd6
commit 26dd9dabca
10 changed files with 72 additions and 12 deletions

8
sprout/range.hpp Normal file
View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_HPP
#define SPROUT_RANGE_HPP
#include <sprout/config.hpp>
#include <sprout/range/range.hpp>
#include <sprout/range/type_traits.hpp>
#endif // #ifndef SPROUT_RANGE_HPP

View file

@ -4,7 +4,7 @@
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/range/lvalue_range.hpp>
#include <sprout/range/type_traits/lvalue_range.hpp>
#include <sprout/algorithm/equal_range.hpp>
namespace sprout {

View file

@ -5,7 +5,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/lvalue_iterator.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/algorithm/mismatch.hpp>
namespace sprout {

View file

@ -0,0 +1,35 @@
#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>
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)
);
}
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

9
sprout/range/range.hpp Normal file
View file

@ -0,0 +1,9 @@
#ifndef SPROUT_RANGE_RANGE_HPP
#define SPROUT_RANGE_RANGE_HPP
#include <sprout/config.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/ptr_range.hpp>
#include <sprout/range/range_return.hpp>
#endif // #ifndef SPROUT_RANGE_RANGE_HPP

View file

@ -6,7 +6,7 @@
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/range/lvalue_iterator.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/utility/swap.hpp>
namespace sprout {

View file

@ -5,8 +5,8 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/range/lvalue_iterator.hpp>
#include <sprout/range/lvalue_range.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/range/type_traits/lvalue_range.hpp>
namespace sprout {
namespace range {

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_TYPE_TRAITS_HPP
#define SPROUT_RANGE_TYPE_TRAITS_HPP
#include <sprout/config.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/range/type_traits/lvalue_range.hpp>
#endif // #ifndef SPROUT_RANGE_TYPE_TRAITS_HPP

View file

@ -1,5 +1,5 @@
#ifndef SPROUT_RANGE_LVALUE_ITERATOR_HPP
#define SPROUT_RANGE_LVALUE_ITERATOR_HPP
#ifndef SPROUT_RANGE_TYPE_TRAITS_LVALUE_ITERATOR_HPP
#define SPROUT_RANGE_TYPE_TRAITS_LVALUE_ITERATOR_HPP
#include <type_traits>
#include <sprout/config.hpp>
@ -21,4 +21,4 @@ namespace sprout {
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_LVALUE_ITERATOR_HPP
#endif // #ifndef SPROUT_RANGE_TYPE_TRAITS_LVALUE_ITERATOR_HPP

View file

@ -1,9 +1,9 @@
#ifndef SPROUT_RANGE_LVALUE_RANGE_HPP
#define SPROUT_RANGE_LVALUE_RANGE_HPP
#ifndef SPROUT_RANGE_TYPE_TRAITS_LVALUE_RANGE_HPP
#define SPROUT_RANGE_TYPE_TRAITS_LVALUE_RANGE_HPP
#include <sprout/config.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/lvalue_iterator.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
namespace sprout {
namespace range {
@ -18,4 +18,4 @@ namespace sprout {
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_LVALUE_RANGE_HPP
#endif // #ifndef SPROUT_RANGE_TYPE_TRAITS_LVALUE_RANGE_HPP