From 26dd9dabca0888868c848f6890426f4040d2505a Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sat, 22 Dec 2012 20:10:27 +0900 Subject: [PATCH] add make_ptr_range --- sprout/range.hpp | 8 +++++ sprout/range/algorithm/equal_range.hpp | 2 +- sprout/range/algorithm/mismatch.hpp | 2 +- sprout/range/ptr_range.hpp | 35 +++++++++++++++++++ sprout/range/range.hpp | 9 +++++ sprout/range/range_container.hpp | 2 +- sprout/range/range_return.hpp | 4 +-- sprout/range/type_traits.hpp | 8 +++++ .../{ => type_traits}/lvalue_iterator.hpp | 6 ++-- .../range/{ => type_traits}/lvalue_range.hpp | 8 ++--- 10 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 sprout/range.hpp create mode 100644 sprout/range/ptr_range.hpp create mode 100644 sprout/range/range.hpp create mode 100644 sprout/range/type_traits.hpp rename sprout/range/{ => type_traits}/lvalue_iterator.hpp (71%) rename sprout/range/{ => type_traits}/lvalue_range.hpp (59%) diff --git a/sprout/range.hpp b/sprout/range.hpp new file mode 100644 index 00000000..e16cce0b --- /dev/null +++ b/sprout/range.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_HPP +#define SPROUT_RANGE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_HPP diff --git a/sprout/range/algorithm/equal_range.hpp b/sprout/range/algorithm/equal_range.hpp index aabd717e..3afbace1 100644 --- a/sprout/range/algorithm/equal_range.hpp +++ b/sprout/range/algorithm/equal_range.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/range/algorithm/mismatch.hpp b/sprout/range/algorithm/mismatch.hpp index e10ce60c..b1ab2513 100644 --- a/sprout/range/algorithm/mismatch.hpp +++ b/sprout/range/algorithm/mismatch.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/range/ptr_range.hpp b/sprout/range/ptr_range.hpp new file mode 100644 index 00000000..b034e2df --- /dev/null +++ b/sprout/range/ptr_range.hpp @@ -0,0 +1,35 @@ +#ifndef SPROUT_RANGE_PTR_RANGE_HPP +#define SPROUT_RANGE_PTR_RANGE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + // + // make_ptr_range + // + template + inline SPROUT_CONSTEXPR sprout::range::range_container > + make_ptr_range(T* p, typename std::iterator_traits::difference_type n) { + return sprout::range::range_container >( + sprout::ptr_index_iterator(p), + sprout::ptr_index_iterator(p, n) + ); + } + + template + inline SPROUT_CONSTEXPR sprout::range::range_container > + make_ptr_range(T (& arr)[N]) { + return sprout::range::range_container >( + sprout::ptr_index_iterator(arr), + sprout::ptr_index_iterator(arr, N) + ); + } + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_PTR_RANGE_HPP diff --git a/sprout/range/range.hpp b/sprout/range/range.hpp new file mode 100644 index 00000000..3f76a4ff --- /dev/null +++ b/sprout/range/range.hpp @@ -0,0 +1,9 @@ +#ifndef SPROUT_RANGE_RANGE_HPP +#define SPROUT_RANGE_RANGE_HPP + +#include +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_RANGE_HPP diff --git a/sprout/range/range_container.hpp b/sprout/range/range_container.hpp index b4c5deb1..9c5b3677 100644 --- a/sprout/range/range_container.hpp +++ b/sprout/range/range_container.hpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include namespace sprout { diff --git a/sprout/range/range_return.hpp b/sprout/range/range_return.hpp index 24e9b0ce..47c00ffd 100644 --- a/sprout/range/range_return.hpp +++ b/sprout/range/range_return.hpp @@ -5,8 +5,8 @@ #include #include #include -#include -#include +#include +#include namespace sprout { namespace range { diff --git a/sprout/range/type_traits.hpp b/sprout/range/type_traits.hpp new file mode 100644 index 00000000..27262eb2 --- /dev/null +++ b/sprout/range/type_traits.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_TYPE_TRAITS_HPP +#define SPROUT_RANGE_TYPE_TRAITS_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_TYPE_TRAITS_HPP diff --git a/sprout/range/lvalue_iterator.hpp b/sprout/range/type_traits/lvalue_iterator.hpp similarity index 71% rename from sprout/range/lvalue_iterator.hpp rename to sprout/range/type_traits/lvalue_iterator.hpp index 817f20ae..2197c0ec 100644 --- a/sprout/range/lvalue_iterator.hpp +++ b/sprout/range/type_traits/lvalue_iterator.hpp @@ -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 #include @@ -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 diff --git a/sprout/range/lvalue_range.hpp b/sprout/range/type_traits/lvalue_range.hpp similarity index 59% rename from sprout/range/lvalue_range.hpp rename to sprout/range/type_traits/lvalue_range.hpp index 05cbd36f..e84760d1 100644 --- a/sprout/range/lvalue_range.hpp +++ b/sprout/range/type_traits/lvalue_range.hpp @@ -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 #include -#include +#include 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