Last active
June 9, 2020 22:08
-
-
Save bstaletic/86eb2bacdd864cc8a54d3fff92bab1bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ 0%] Building CXX object test/CMakeFiles/test_nanorange.dir/algorithm/partition.cpp.o | |
In file included from /home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:25: | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp: In instantiation of ‘static constexpr nano::ranges::subrange_::subrange<I> nano::ranges::detail::partition_fn::impl(I, S, Pred&, Proj&) [with I = forward_iterator<int*>; S = sentinel<int*>; Pred = {anonymous}::is_odd; Proj = nano::ranges::identity]’: | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:50:34: required from ‘void {anonymous}::test_iter() [with Iter = forward_iterator<int*>; Sent = sentinel<int*>]’ | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:203:53: required from here | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:47:26: in ‘constexpr’ expansion of ‘nano::ranges::function_objects::partition.nano::ranges::detail::partition_fn::operator()<forward_iterator<int*>, sentinel<int*>, {anonymous}::is_odd>(forward_iterator<int*>(((int*)(& ia))), sentinel<int*>((((int*)(& ia)) + ((sizetype)(((long unsigned int)sa) * 4)))), ({anonymous}::is_odd(), {anonymous}::is_odd()), (nano::ranges::identity{}, nano::ranges::identity()))’ | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:27:32: error: could not convert ‘{first, last}’ from ‘<brace-enclosed initializer list>’ to ‘nano::ranges::subrange_::subrange<forward_iterator<int*>, forward_iterator<int*>, nano::ranges::subrange_kind::unsized>’ | |
27 | return {first, last}; | |
| ^ | |
| | | |
| <brace-enclosed initializer list> | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:47:26: in ‘constexpr’ expansion of ‘nano::ranges::function_objects::partition.nano::ranges::detail::partition_fn::operator()<forward_iterator<int*>, sentinel<int*>, {anonymous}::is_odd>(forward_iterator<int*>(((int*)(& ia))), sentinel<int*>((((int*)(& ia)) + ((sizetype)(((long unsigned int)sa) * 4)))), ({anonymous}::is_odd(), {anonymous}::is_odd()), (nano::ranges::identity{}, nano::ranges::identity()))’ | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:40:21: error: could not convert ‘{first, last}’ from ‘<brace-enclosed initializer list>’ to ‘nano::ranges::subrange_::subrange<forward_iterator<int*>, forward_iterator<int*>, nano::ranges::subrange_kind::unsized>’ | |
40 | return {first, last}; | |
| ^ | |
| | | |
| <brace-enclosed initializer list> | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp: In instantiation of ‘static constexpr nano::ranges::subrange_::subrange<I> nano::ranges::detail::partition_fn::impl(I, S, Pred&, Proj&) [with I = bidirectional_iterator<int*>; S = sentinel<int*>; Pred = {anonymous}::is_odd; Proj = nano::ranges::identity]’: | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:50:34: required from ‘void {anonymous}::test_iter() [with Iter = bidirectional_iterator<int*>; Sent = sentinel<int*>]’ | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:204:59: required from here | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:47:26: in ‘constexpr’ expansion of ‘nano::ranges::function_objects::partition.nano::ranges::detail::partition_fn::operator()<bidirectional_iterator<int*>, sentinel<int*>, {anonymous}::is_odd>(bidirectional_iterator<int*>(((int*)(& ia))), sentinel<int*>((((int*)(& ia)) + ((sizetype)(((long unsigned int)sa) * 4)))), ({anonymous}::is_odd(), {anonymous}::is_odd()), (nano::ranges::identity{}, nano::ranges::identity()))’ | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:27:32: error: could not convert ‘{first, last}’ from ‘<brace-enclosed initializer list>’ to ‘nano::ranges::subrange_::subrange<bidirectional_iterator<int*>, bidirectional_iterator<int*>, nano::ranges::subrange_kind::unsized>’ | |
27 | return {first, last}; | |
| ^ | |
| | | |
| <brace-enclosed initializer list> | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:47:26: in ‘constexpr’ expansion of ‘nano::ranges::function_objects::partition.nano::ranges::detail::partition_fn::operator()<bidirectional_iterator<int*>, sentinel<int*>, {anonymous}::is_odd>(bidirectional_iterator<int*>(((int*)(& ia))), sentinel<int*>((((int*)(& ia)) + ((sizetype)(((long unsigned int)sa) * 4)))), ({anonymous}::is_odd(), {anonymous}::is_odd()), (nano::ranges::identity{}, nano::ranges::identity()))’ | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:40:21: error: could not convert ‘{first, last}’ from ‘<brace-enclosed initializer list>’ to ‘nano::ranges::subrange_::subrange<bidirectional_iterator<int*>, bidirectional_iterator<int*>, nano::ranges::subrange_kind::unsized>’ | |
40 | return {first, last}; | |
| ^ | |
| | | |
| <brace-enclosed initializer list> | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp: In instantiation of ‘static constexpr nano::ranges::subrange_::subrange<I> nano::ranges::detail::partition_fn::impl(I, S, Pred&, Proj&) [with I = random_access_iterator<int*>; S = sentinel<int*>; Pred = {anonymous}::is_odd; Proj = nano::ranges::identity]’: | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:50:34: required from ‘void {anonymous}::test_iter() [with Iter = random_access_iterator<int*>; Sent = sentinel<int*>]’ | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:205:59: required from here | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:47:26: in ‘constexpr’ expansion of ‘nano::ranges::function_objects::partition.nano::ranges::detail::partition_fn::operator()<random_access_iterator<int*>, sentinel<int*>, {anonymous}::is_odd>(random_access_iterator<int*>(((int*)(& ia))), sentinel<int*>((((int*)(& ia)) + ((sizetype)(((long unsigned int)sa) * 4)))), ({anonymous}::is_odd(), {anonymous}::is_odd()), (nano::ranges::identity{}, nano::ranges::identity()))’ | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:27:32: error: could not convert ‘{first, last}’ from ‘<brace-enclosed initializer list>’ to ‘nano::ranges::subrange_::subrange<random_access_iterator<int*>, random_access_iterator<int*>, nano::ranges::subrange_kind::sized>’ | |
27 | return {first, last}; | |
| ^ | |
| | | |
| <brace-enclosed initializer list> | |
/home/bstaletic/work/NanoRange/test/algorithm/partition.cpp:47:26: in ‘constexpr’ expansion of ‘nano::ranges::function_objects::partition.nano::ranges::detail::partition_fn::operator()<random_access_iterator<int*>, sentinel<int*>, {anonymous}::is_odd>(random_access_iterator<int*>(((int*)(& ia))), sentinel<int*>((((int*)(& ia)) + ((sizetype)(((long unsigned int)sa) * 4)))), ({anonymous}::is_odd(), {anonymous}::is_odd()), (nano::ranges::identity{}, nano::ranges::identity()))’ | |
/home/bstaletic/work/NanoRange/include/nanorange/algorithm/partition.hpp:40:21: error: could not convert ‘{first, last}’ from ‘<brace-enclosed initializer list>’ to ‘nano::ranges::subrange_::subrange<random_access_iterator<int*>, random_access_iterator<int*>, nano::ranges::subrange_kind::sized>’ | |
40 | return {first, last}; | |
| ^ | |
| | | |
| <brace-enclosed initializer list> | |
make[2]: *** [test/CMakeFiles/test_nanorange.dir/build.make:954: test/CMakeFiles/test_nanorange.dir/algorithm/partition.cpp.o] Error 1 | |
make[1]: *** [CMakeFiles/Makefile2:898: test/CMakeFiles/test_nanorange.dir/all] Error 2 | |
make: *** [Makefile:115: all] Error 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/nanorange/algorithm/count.hpp b/include/nanorange/algorithm/count.hpp | |
index cb55e13..f33b232 100644 | |
--- a/include/nanorange/algorithm/count.hpp | |
+++ b/include/nanorange/algorithm/count.hpp | |
@@ -51,7 +51,7 @@ public: | |
constexpr std::enable_if_t< | |
input_range<Rng> && | |
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>>, | |
- iter_difference_t<iterator_t<Rng>>> | |
+ range_difference_t<Rng>> | |
operator()(Rng&& rng, Pred pred, Proj proj = Proj{}) const | |
{ | |
return count_if_fn::impl(nano::begin(rng), nano::end(rng), | |
@@ -82,7 +82,7 @@ struct count_fn { | |
input_range<Rng> && | |
indirect_relation<ranges::equal_to, projected<iterator_t<Rng>, Proj>, | |
const T*>, | |
- iter_difference_t<iterator_t<Rng>>> | |
+ range_difference_t<Rng>> | |
operator()(Rng&& rng, const T& value, Proj proj = Proj{}) const | |
{ | |
const auto pred = [&value] (const auto& t) { return t == value; }; | |
diff --git a/include/nanorange/algorithm/max.hpp b/include/nanorange/algorithm/max.hpp | |
index 4d94629..4f69454 100644 | |
--- a/include/nanorange/algorithm/max.hpp | |
+++ b/include/nanorange/algorithm/max.hpp | |
@@ -63,7 +63,7 @@ public: | |
constexpr std::enable_if_t< | |
input_range<Rng> && copyable<iter_value_t<iterator_t<Rng>>> && | |
indirect_strict_weak_order<Comp, projected<iterator_t<Rng>, Proj>>, | |
- iter_value_t<iterator_t<Rng>>> | |
+ range_value_t<Rng>> | |
operator()(Rng&& rng, Comp comp = Comp{}, Proj proj = Proj{}) const | |
{ | |
return max_fn::impl(std::forward<Rng>(rng), comp, proj); | |
diff --git a/include/nanorange/algorithm/min.hpp b/include/nanorange/algorithm/min.hpp | |
index 92ba4d1..2c6d546 100644 | |
--- a/include/nanorange/algorithm/min.hpp | |
+++ b/include/nanorange/algorithm/min.hpp | |
@@ -62,7 +62,7 @@ public: | |
constexpr std::enable_if_t< | |
input_range<Rng> && copyable<iter_value_t<iterator_t<Rng>>> && | |
indirect_strict_weak_order<Comp, projected<iterator_t<Rng>, Proj>>, | |
- iter_value_t<iterator_t<Rng>>> | |
+ range_value_t<Rng>> | |
operator()(Rng&& rng, Comp comp = Comp{}, Proj proj = Proj{}) const | |
{ | |
return min_fn::impl(std::forward<Rng>(rng), comp, proj); | |
diff --git a/include/nanorange/algorithm/minmax.hpp b/include/nanorange/algorithm/minmax.hpp | |
index 7433b2d..d5696bc 100644 | |
--- a/include/nanorange/algorithm/minmax.hpp | |
+++ b/include/nanorange/algorithm/minmax.hpp | |
@@ -134,7 +134,7 @@ public: | |
constexpr std::enable_if_t< | |
input_range<Rng> && copyable<iter_value_t<iterator_t<Rng>>> && | |
indirect_strict_weak_order<Comp, projected<iterator_t<Rng>, Proj>>, | |
- minmax_result<iter_value_t<iterator_t<Rng>>>> | |
+ minmax_result<range_value_t<Rng>>> | |
operator()(Rng&& rng, Comp comp = Comp{}, Proj proj = Proj{}) const | |
{ | |
return minmax_fn::impl(std::forward<Rng>(rng), comp, proj); | |
diff --git a/include/nanorange/algorithm/minmax_element.hpp b/include/nanorange/algorithm/minmax_element.hpp | |
index ecdec77..9af8caa 100644 | |
--- a/include/nanorange/algorithm/minmax_element.hpp | |
+++ b/include/nanorange/algorithm/minmax_element.hpp | |
@@ -14,14 +14,17 @@ | |
NANO_BEGIN_NAMESPACE | |
+template <typename T> | |
+using minmax_element_result = minmax_result<T>; | |
+ | |
namespace detail { | |
struct minmax_element_fn { | |
private: | |
template <typename I, typename S, typename Comp, typename Proj> | |
- static constexpr minmax_result<I> impl(I first, S last, Comp& comp, Proj& proj) | |
+ static constexpr minmax_element_result<I> impl(I first, S last, Comp& comp, Proj& proj) | |
{ | |
- minmax_result<I> result{first, first}; | |
+ minmax_element_result<I> result{first, first}; | |
if (first == last || ++first == last) { | |
return result; | |
@@ -84,7 +87,7 @@ public: | |
constexpr std::enable_if_t< | |
forward_iterator<I> && sentinel_for<S, I> && | |
indirect_strict_weak_order<Comp, projected<I, Proj>>, | |
- minmax_result<I>> | |
+ minmax_element_result<I>> | |
operator()(I first, S last, Comp comp = Comp{}, Proj proj = Proj{}) const | |
{ | |
return minmax_element_fn::impl(std::move(first), std::move(last), | |
@@ -95,7 +98,7 @@ public: | |
constexpr std::enable_if_t< | |
forward_range<Rng> && | |
indirect_strict_weak_order<Comp, projected<iterator_t<Rng>, Proj>>, | |
- minmax_result<borrowed_iterator_t<Rng>>> | |
+ minmax_element_result<borrowed_iterator_t<Rng>>> | |
operator()(Rng&& rng, Comp comp = Comp{}, Proj proj = Proj{}) const | |
{ | |
return minmax_element_fn::impl(nano::begin(rng), nano::end(rng), | |
diff --git a/include/nanorange/algorithm/partial_sort_copy.hpp b/include/nanorange/algorithm/partial_sort_copy.hpp | |
index 3fb16c2..25611e9 100644 | |
--- a/include/nanorange/algorithm/partial_sort_copy.hpp | |
+++ b/include/nanorange/algorithm/partial_sort_copy.hpp | |
@@ -7,23 +7,27 @@ | |
#ifndef NANORANGE_ALGORITHM_PARTIAL_SORT_COPY_HPP_INCLUDED | |
#define NANORANGE_ALGORITHM_PARTIAL_SORT_COPY_HPP_INCLUDED | |
+#include <nanorange/algorithm/copy.hpp> | |
#include <nanorange/algorithm/make_heap.hpp> | |
#include <nanorange/algorithm/sort_heap.hpp> | |
NANO_BEGIN_NAMESPACE | |
+template <typename I, typename O> | |
+using partial_sort_copy_result = copy_result<I, O>; | |
+ | |
namespace detail { | |
struct partial_sort_copy_fn { | |
private: | |
template <typename I1, typename S1, typename I2, typename S2, | |
typename Comp, typename Proj1, typename Proj2> | |
- static constexpr I2 impl(I1 first, S1 last, I2 result_first, | |
+ static constexpr partial_sort_copy_result<I1, I2> impl(I1 first, S1 last, I2 result_first, | |
S2 result_last, Comp& comp, Proj1& proj1, Proj2& proj2) | |
{ | |
I2 r = result_first; | |
if (r == result_last) { | |
- return r; | |
+ return {first, result_first}; | |
} | |
while (r != result_last && first != last) { | |
@@ -46,7 +50,7 @@ private: | |
nano::sort_heap(result_first, r, comp, proj2); | |
- return r; | |
+ return {first, r}; | |
} | |
public: | |
@@ -58,7 +62,7 @@ public: | |
sentinel_for<S2, I2> && | |
indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> && | |
indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>, | |
- I2> | |
+ partial_sort_copy_result<I1, I2>> | |
operator()(I1 first, S1 last, I2 result_first, S2 result_last, Comp comp = Comp{}, | |
Proj1 proj1 = Proj1{}, Proj2 proj2 = Proj2{}) const | |
{ | |
@@ -74,7 +78,7 @@ public: | |
indirectly_copyable<iterator_t<Rng1>, iterator_t<Rng2>> && | |
sortable<iterator_t<Rng2>, Comp, Proj2> && | |
indirect_strict_weak_order<Comp, projected<iterator_t<Rng1>, Proj1>, projected<iterator_t<Rng2>, Proj2>>, | |
- borrowed_iterator_t<Rng2>> | |
+ partial_sort_copy_result<borrowed_iterator_t<Rng1>, borrowed_iterator_t<Rng2>>> | |
operator()(Rng1&& rng, Rng2&& result_rng, Comp comp = Comp{}, | |
Proj1 proj1 = Proj1{}, Proj2 proj2 = Proj2{}) const | |
{ | |
diff --git a/include/nanorange/algorithm/partition.hpp b/include/nanorange/algorithm/partition.hpp | |
index b8d9834..65deee3 100644 | |
--- a/include/nanorange/algorithm/partition.hpp | |
+++ b/include/nanorange/algorithm/partition.hpp | |
@@ -7,7 +7,10 @@ | |
#ifndef NANORANGE_ALGORITHM_PARTITION_HPP_INCLUDED | |
#define NANORANGE_ALGORITHM_PARTITION_HPP_INCLUDED | |
+#include <nanorange/ranges.hpp> | |
+ | |
#include <nanorange/algorithm/find.hpp> | |
+#include <nanorange/views/subrange.hpp> | |
NANO_BEGIN_NAMESPACE | |
@@ -16,12 +19,12 @@ namespace detail { | |
struct partition_fn { | |
private: | |
template <typename I, typename S, typename Pred, typename Proj> | |
- static constexpr I impl(I first, S last, Pred& pred, Proj& proj) | |
+ static constexpr subrange<I> impl(I first, S last, Pred& pred, Proj& proj) | |
{ | |
first = nano::find_if_not(std::move(first), last, pred, proj); | |
if (first == last) { | |
- return first; | |
+ return {first, last}; | |
} | |
auto n = nano::next(first); | |
@@ -34,14 +37,14 @@ private: | |
++n; | |
} | |
- return first; | |
+ return {first, last}; | |
} | |
public: | |
template <typename I, typename S, typename Pred, typename Proj = identity> | |
constexpr std::enable_if_t< | |
forward_iterator<I> && sentinel_for<S, I> && | |
- indirect_unary_predicate<Pred, projected<I, Proj>>, I> | |
+ indirect_unary_predicate<Pred, projected<I, Proj>>, subrange<I>> | |
operator()(I first, S last, Pred pred, Proj proj = Proj{}) const | |
{ | |
return partition_fn::impl(std::move(first), std::move(last), | |
@@ -52,7 +55,7 @@ public: | |
constexpr std::enable_if_t< | |
forward_range<Rng> && | |
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>>, | |
- borrowed_iterator_t<Rng>> | |
+ borrowed_subrange_t<Rng>> | |
operator()(Rng&& rng, Pred pred, Proj proj = Proj{}) const | |
{ | |
return partition_fn::impl(nano::begin(rng), nano::end(rng), | |
diff --git a/include/nanorange/algorithm/stable_partition.hpp b/include/nanorange/algorithm/stable_partition.hpp | |
index f29553b..0ee6df0 100644 | |
--- a/include/nanorange/algorithm/stable_partition.hpp | |
+++ b/include/nanorange/algorithm/stable_partition.hpp | |
@@ -23,6 +23,7 @@ | |
#include <nanorange/iterator/back_insert_iterator.hpp> | |
#include <nanorange/iterator/move_iterator.hpp> | |
#include <nanorange/iterator/reverse_iterator.hpp> | |
+#include <nanorange/views/subrange.hpp> | |
#include <nanorange/detail/memory/temporary_vector.hpp> | |
@@ -33,7 +34,7 @@ namespace detail { | |
struct stable_partition_fn { | |
private: | |
template <typename I, typename Buf, typename Pred, typename Proj> | |
- static I impl_buffered(I first, I last, Buf& buf, Pred& pred, Proj& proj) | |
+ static subrange<I> impl_buffered(I first, I last, Buf& buf, Pred& pred, Proj& proj) | |
{ | |
// first is known to be false, so pop it straight into the buffer | |
buf.push_back(nano::iter_move(first)); | |
@@ -51,12 +52,12 @@ private: | |
// Now move all the other elements from the buffer back into the sequence | |
nano::move(buf, first); | |
- return first; | |
+ return {first, last}; | |
} | |
// Note to self: this is a closed range, last is NOT past-the-end! | |
template <typename I, typename Pred, typename Proj> | |
- static I impl_unbuffered(I first, I last, iter_difference_t<I> dist, | |
+ static subrange<I> impl_unbuffered(I first, I last, iter_difference_t<I> dist, | |
Pred& pred, Proj& proj) | |
{ | |
using dist_t = iter_difference_t<I>; | |
@@ -64,7 +65,7 @@ private: | |
if (dist == 2) { | |
// We know first is false and last is true, so swap them | |
nano::iter_swap(first, last); | |
- return last; | |
+ return {first, last}; | |
} | |
if (dist == 3) { | |
@@ -74,13 +75,13 @@ private: | |
if (nano::invoke(pred, nano::invoke(proj, *middle))) { | |
nano::iter_swap(first, middle); | |
nano::iter_swap(middle, last); | |
- return last; | |
+ return {first, last}; | |
} | |
// middle is false | |
nano::iter_swap(middle, last); | |
nano::iter_swap(first, middle); | |
- return middle; | |
+ return {first, middle}; | |
} | |
const dist_t half = dist/2; | |
@@ -95,29 +96,31 @@ private: | |
} | |
const I first_false = (m1 == first) ? first : | |
- impl_unbuffered(first, m1, len_half, pred, proj); | |
+ impl_unbuffered(first, m1, len_half, pred, proj).end(); | |
m1 = middle; | |
len_half = dist - half; | |
while (nano::invoke(pred, nano::invoke(proj, *m1))) { | |
if (++m1 == last) { | |
- return nano::rotate(first_false, middle, ++last).begin(); | |
+ auto rot = nano::rotate(first_false, middle, ++last); | |
+ return {rot.begin(), rot.end()}; | |
} | |
} | |
- const I last_false = impl_unbuffered(m1, last, len_half, pred, proj); | |
+ const I last_false = impl_unbuffered(m1, last, len_half, pred, proj).end(); | |
- return nano::rotate(first_false, middle, last_false).begin(); | |
+ auto rot = nano::rotate(first_false, middle, last_false); | |
+ return {rot.begin(), rot.end()}; | |
} | |
template <typename I, typename Pred, typename Proj> | |
- static I impl(I first, I last, Pred& pred, Proj& proj) | |
+ static subrange<I> impl(I first, I last, Pred& pred, Proj& proj) | |
{ | |
// Find the first non-true value | |
first = nano::find_if_not(std::move(first), last, std::ref(pred), std::ref(proj)); | |
if (first == last) { | |
- return first; | |
+ return {first, last}; | |
} | |
// Find the last true value | |
@@ -125,7 +128,7 @@ private: | |
nano::make_reverse_iterator(first), | |
std::ref(pred), std::ref(proj)).base(); | |
if (last == first) { | |
- return first; | |
+ return {first, last}; | |
} | |
const auto dist = nano::distance(first, last); | |
@@ -138,7 +141,7 @@ private: | |
} | |
template <typename I, typename S, typename Pred, typename Proj> | |
- static std::enable_if_t<!same_as<I, S>, I> | |
+ static std::enable_if_t<!same_as<I, S>, subrange<I>> | |
impl(I first, S last, Pred& pred, Proj& proj) | |
{ | |
return impl(first, nano::next(first, last), pred, proj); | |
@@ -148,7 +151,7 @@ public: | |
template <typename I, typename S, typename Pred, typename Proj = identity> | |
std::enable_if_t<bidirectional_iterator<I> && sentinel_for<S, I> && | |
indirect_unary_predicate<Pred, projected<I, Proj>> && | |
- permutable<I>, I> | |
+ permutable<I>, subrange<I>> | |
operator()(I first, S last, Pred pred, Proj proj = Proj{}) const | |
{ | |
return stable_partition_fn::impl(std::move(first), std::move(last), | |
@@ -160,7 +163,7 @@ public: | |
bidirectional_range<Rng> && | |
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>> && | |
permutable<iterator_t<Rng>>, | |
- borrowed_iterator_t<Rng>> | |
+ borrowed_subrange_t<Rng>> | |
operator()(Rng&& rng, Pred pred, Proj proj = Proj{}) const | |
{ | |
return stable_partition_fn::impl(nano::begin(rng), nano::end(rng), | |
diff --git a/include/nanorange/algorithm/unique.hpp b/include/nanorange/algorithm/unique.hpp | |
index 9d6a568..4c5f1b0 100644 | |
--- a/include/nanorange/algorithm/unique.hpp | |
+++ b/include/nanorange/algorithm/unique.hpp | |
@@ -10,6 +10,7 @@ | |
#include <nanorange/ranges.hpp> | |
#include <nanorange/algorithm/adjacent_find.hpp> | |
+#include <nanorange/views/subrange.hpp> | |
NANO_BEGIN_NAMESPACE | |
@@ -18,12 +19,12 @@ namespace detail { | |
struct unique_fn { | |
private: | |
template <typename I, typename S, typename R, typename Proj> | |
- static constexpr I impl(I first, S last, R& comp, Proj& proj) | |
+ static constexpr subrange<I> impl(I first, S last, R& comp, Proj& proj) | |
{ | |
first = adjacent_find_fn::impl(std::move(first), last, comp, proj); | |
if (first == last) { | |
- return first; | |
+ return {first, last}; | |
} | |
for (I n = next(first, 2, last); n != last; ++n) { | |
@@ -33,7 +34,7 @@ private: | |
} | |
} | |
- return ++first; | |
+ return {++first, last}; | |
} | |
public: | |
@@ -41,7 +42,7 @@ public: | |
typename Proj = identity> | |
constexpr std::enable_if_t<forward_iterator<I> && sentinel_for<S, I> && | |
indirect_relation<R, projected<I, Proj>> && | |
- permutable<I>, I> | |
+ permutable<I>, subrange<I>> | |
operator()(I first, S last, R comp = {}, Proj proj = Proj{}) const | |
{ | |
return unique_fn::impl(std::move(first), std::move(last), | |
@@ -53,7 +54,7 @@ public: | |
forward_range<Rng> && | |
indirect_relation<R, projected<iterator_t<Rng>, Proj>> && | |
permutable<iterator_t<Rng>>, | |
- borrowed_iterator_t<Rng>> | |
+ borrowed_subrange_t<Rng>> | |
operator()(Rng&& rng, R comp = {}, Proj proj = Proj{}) const | |
{ | |
return unique_fn::impl(nano::begin(rng), nano::end(rng), | |
diff --git a/test/algorithm/partial_sort_copy.cpp b/test/algorithm/partial_sort_copy.cpp | |
index d93a75c..d64c785 100644 | |
--- a/test/algorithm/partial_sort_copy.cpp | |
+++ b/test/algorithm/partial_sort_copy.cpp | |
@@ -41,7 +41,7 @@ test_larger_sorts(int N, int M) | |
auto partial_sort_copy = ::make_testable_2<true, false>( | |
[](auto&& ... args) { | |
return stl2::partial_sort_copy( | |
- std::forward<decltype(args)>(args)...); | |
+ std::forward<decltype(args)>(args)...).out; | |
}); | |
int* input = new int[N]; | |
int* output = new int[M]; | |
@@ -121,8 +121,9 @@ struct U { | |
TEST_CASE("alg.partial_sort_copy") | |
{ | |
int i = 0; | |
- int * r = stl2::partial_sort_copy(&i, &i, &i, &i+5); | |
- CHECK(r == &i); | |
+ stl2::partial_sort_copy_result r = stl2::partial_sort_copy(&i, &i, &i, &i+5); | |
+ CHECK(r.in == &i); | |
+ CHECK(r.out == &i); | |
CHECK(i == 0); | |
test<input_iterator<const int*> >(); | |
test<forward_iterator<const int*> >(); | |
@@ -139,11 +140,13 @@ TEST_CASE("alg.partial_sort_copy") | |
for (int i = 0; i < N; ++i) | |
input[i].i = i; | |
std::shuffle(input, input+N, gen); | |
- U* r = stl2::partial_sort_copy(input, output, std::less<int>(), &S::i, &U::i); | |
- U* e = output + std::min(N, M); | |
- CHECK(r == e); | |
+ stl2::partial_sort_copy_result r = stl2::partial_sort_copy(input, output, std::less<int>(), &S::i, &U::i); | |
+ S* e_in = input + std::min(N, M); | |
+ U* e_out = output + std::min(N, M); | |
+ CHECK(r.in == e_in); | |
+ CHECK(r.out == e_out); | |
int i = 0; | |
- for (U* x = output; x < e; ++x, ++i) | |
+ for (U* x = output; x < e_out; ++x, ++i) | |
CHECK(x->i == i); | |
} | |
@@ -156,10 +159,9 @@ TEST_CASE("alg.partial_sort_copy") | |
for (int i = 0; i < N; ++i) | |
input[i].i = i; | |
std::shuffle(input, input+N, gen); | |
- auto r = stl2::partial_sort_copy(input, std::move(output), std::less<int>(), &S::i, &U::i); | |
+ auto r = stl2::partial_sort_copy(input, std::move(output), std::less<int>(), &S::i, &U::i).out; | |
static_assert(stl2::same_as<decltype(r), stl2::dangling>); | |
U* e = output.data() + std::min(N, M); | |
- //CHECK(r.get_unsafe() == e); | |
int i = 0; | |
for (U* x = output.data(); x < e; ++x, ++i) | |
CHECK(x->i == i); | |
diff --git a/test/algorithm/partition.cpp b/test/algorithm/partition.cpp | |
index c5cff33..d5ab5ed 100644 | |
--- a/test/algorithm/partition.cpp | |
+++ b/test/algorithm/partition.cpp | |
@@ -44,30 +44,30 @@ test_iter() | |
// check mixed | |
int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; | |
const unsigned sa = sizeof(ia) / sizeof(ia[0]); | |
- Iter r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()); | |
+ auto r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()).end(); | |
CHECK(base(r) == ia + 5); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
for (int* i = base(r); i < ia + sa; ++i) | |
CHECK(!is_odd()(*i)); | |
// check empty | |
- r = stl2::partition(Iter(ia), Sent(ia), is_odd()); | |
+ r = stl2::partition(Iter(ia), Sent(ia), is_odd()).end(); | |
CHECK(base(r) == ia); | |
// check all false | |
for (unsigned i = 0; i < sa; ++i) | |
ia[i] = 2 * i; | |
- r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()); | |
+ r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()).end(); | |
CHECK(base(r) == ia); | |
// check all true | |
for (unsigned i = 0; i < sa; ++i) | |
ia[i] = 2 * i + 1; | |
- r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()); | |
+ r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()).end(); | |
CHECK(base(r) == ia + sa); | |
// check all true but last | |
for (unsigned i = 0; i < sa; ++i) | |
ia[i] = 2 * i + 1; | |
ia[sa - 1] = 10; | |
- r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()); | |
+ r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()).end(); | |
CHECK(base(r) == ia + sa - 1); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -77,7 +77,7 @@ test_iter() | |
for (unsigned i = 0; i < sa; ++i) | |
ia[i] = 2 * i + 1; | |
ia[0] = 10; | |
- r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()); | |
+ r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()).end(); | |
CHECK(base(r) == ia + sa - 1); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -87,7 +87,7 @@ test_iter() | |
for (unsigned i = 0; i < sa; ++i) | |
ia[i] = 2 * i; | |
ia[sa - 1] = 11; | |
- r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()); | |
+ r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()).end(); | |
CHECK(base(r) == ia + 1); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -97,7 +97,7 @@ test_iter() | |
for (unsigned i = 0; i < sa; ++i) | |
ia[i] = 2 * i; | |
ia[0] = 11; | |
- r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()); | |
+ r = stl2::partition(Iter(ia), Sent(ia + sa), is_odd()).end(); | |
CHECK(base(r) == ia + 1); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -114,7 +114,7 @@ test_range() | |
const unsigned sa = sizeof(ia) / sizeof(ia[0]); | |
Iter r = stl2::partition( | |
::as_lvalue(stl2::subrange(Iter(ia), Sent(ia + sa))), | |
- is_odd()); | |
+ is_odd()).end(); | |
CHECK(base(r) == ia + 5); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -122,21 +122,21 @@ test_range() | |
CHECK(!is_odd()(*i)); | |
// check empty | |
r = stl2::partition(::as_lvalue(stl2::subrange(Iter(ia), Sent(ia))), | |
- is_odd()); | |
+ is_odd()).end(); | |
CHECK(base(r) == ia); | |
// check all false | |
for (unsigned i = 0; i < sa; ++i) | |
ia[i] = 2 * i; | |
r = stl2::partition( | |
::as_lvalue(stl2::subrange(Iter(ia), Sent(ia + sa))), | |
- is_odd()); | |
+ is_odd()).end(); | |
CHECK(base(r) == ia); | |
// check all true | |
for (unsigned i = 0; i < sa; ++i) | |
ia[i] = 2 * i + 1; | |
r = stl2::partition( | |
::as_lvalue(stl2::subrange(Iter(ia), Sent(ia + sa))), | |
- is_odd()); | |
+ is_odd()).end(); | |
CHECK(base(r) == ia + sa); | |
// check all true but last | |
for (unsigned i = 0; i < sa; ++i) | |
@@ -144,7 +144,7 @@ test_range() | |
ia[sa - 1] = 10; | |
r = stl2::partition( | |
::as_lvalue(stl2::subrange(Iter(ia), Sent(ia + sa))), | |
- is_odd()); | |
+ is_odd()).end(); | |
CHECK(base(r) == ia + sa - 1); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -156,7 +156,7 @@ test_range() | |
ia[0] = 10; | |
r = stl2::partition( | |
::as_lvalue(stl2::subrange(Iter(ia), Sent(ia + sa))), | |
- is_odd()); | |
+ is_odd()).end(); | |
CHECK(base(r) == ia + sa - 1); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -168,7 +168,7 @@ test_range() | |
ia[sa - 1] = 11; | |
r = stl2::partition( | |
::as_lvalue(stl2::subrange(Iter(ia), Sent(ia + sa))), | |
- is_odd()); | |
+ is_odd()).end(); | |
CHECK(base(r) == ia + 1); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -180,7 +180,7 @@ test_range() | |
ia[0] = 11; | |
r = stl2::partition( | |
::as_lvalue(stl2::subrange(Iter(ia), Sent(ia + sa))), | |
- is_odd()); | |
+ is_odd()).end(); | |
CHECK(base(r) == ia + 1); | |
for (int* i = ia; i < base(r); ++i) | |
CHECK(is_odd()(*i)); | |
@@ -215,7 +215,7 @@ TEST_CASE("alg.partition") | |
// Test projections | |
S ia[] = {S{1}, S{2}, S{3}, S{4}, S{5}, S{6}, S{7}, S{8} ,S{9}}; | |
const unsigned sa = sizeof(ia)/sizeof(ia[0]); | |
- S* r = stl2::partition(ia, is_odd(), &S::i); | |
+ auto r = stl2::partition(ia, is_odd(), &S::i).end(); | |
CHECK(r == ia + 5); | |
for (S* i = ia; i < r; ++i) | |
CHECK(is_odd()(i->i)); | |
@@ -223,7 +223,7 @@ TEST_CASE("alg.partition") | |
CHECK(!is_odd()(i->i)); | |
// Test rvalue range | |
- auto r2 = stl2::partition(stl2::subrange(ia), is_odd(), &S::i); | |
+ auto r2 = stl2::partition(stl2::subrange(ia), is_odd(), &S::i).end(); | |
CHECK(r2 == ia + 5); | |
for (S* i = ia; i < r2; ++i) | |
CHECK(is_odd()(i->i)); | |
diff --git a/test/algorithm/stable_partition.cpp b/test/algorithm/stable_partition.cpp | |
index f4e55f1..3cc7c4e 100644 | |
--- a/test/algorithm/stable_partition.cpp | |
+++ b/test/algorithm/stable_partition.cpp | |
@@ -66,7 +66,7 @@ test_iter() | |
{4, 2}}; | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition(Iter(ap), Sent(ap + size), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 4); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{1, 2}); | |
@@ -92,7 +92,7 @@ test_iter() | |
{4, 2}}; | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition(Iter(ap), Sent(ap + size), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 4); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{1, 2}); | |
@@ -105,14 +105,14 @@ test_iter() | |
CHECK(ap[8] == P{4, 1}); | |
CHECK(ap[9] == P{4, 2}); | |
// check empty | |
- r = ranges::stable_partition(Iter(ap), Sent(ap), odd_first()); | |
+ r = ranges::stable_partition(Iter(ap), Sent(ap), odd_first()).end(); | |
CHECK(base(r) == ap); | |
// check one true | |
- r = ranges::stable_partition(Iter(ap), Sent(ap + 1), odd_first()); | |
+ r = ranges::stable_partition(Iter(ap), Sent(ap + 1), odd_first()).end(); | |
CHECK(base(r) == ap + 1); | |
CHECK(ap[0] == P{1, 1}); | |
// check one false | |
- r = ranges::stable_partition(Iter(ap + 4), Sent(ap + 5), odd_first()); | |
+ r = ranges::stable_partition(Iter(ap + 4), Sent(ap + 5), odd_first()).end(); | |
CHECK(base(r) == ap + 4); | |
CHECK(ap[4] == P{0, 1}); | |
} | |
@@ -129,7 +129,7 @@ test_iter() | |
{8, 2}}; | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition(Iter(ap), Sent(ap + size), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap); | |
CHECK(ap[0] == P{0, 1}); | |
CHECK(ap[1] == P{0, 2}); | |
@@ -155,7 +155,7 @@ test_iter() | |
{9, 2}}; | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition(Iter(ap), Sent(ap + size), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + size); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{1, 2}); | |
@@ -181,7 +181,7 @@ test_iter() | |
{8, 2}}; | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition(Iter(ap), Sent(ap + size), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 1); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{0, 2}); | |
@@ -207,7 +207,7 @@ test_iter() | |
{1, 2}}; | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition(Iter(ap), Sent(ap + size), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 1); | |
CHECK(ap[0] == P{1, 2}); | |
CHECK(ap[1] == P{0, 1}); | |
@@ -233,7 +233,7 @@ test_iter() | |
{9, 2}}; | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition(Iter(ap), Sent(ap + size), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + size - 1); | |
CHECK(ap[0] == P{1, 2}); | |
CHECK(ap[1] == P{3, 1}); | |
@@ -259,7 +259,7 @@ test_iter() | |
{0, 2}}; | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition(Iter(ap), Sent(ap + size), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + size - 1); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{1, 2}); | |
@@ -293,7 +293,7 @@ test_range() | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + size))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 4); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{1, 2}); | |
@@ -320,7 +320,7 @@ test_range() | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + size))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 4); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{1, 2}); | |
@@ -335,18 +335,18 @@ test_range() | |
// check empty | |
r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap); | |
// check one true | |
r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + 1))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 1); | |
CHECK(ap[0] == P{1, 1}); | |
// check one false | |
r = ranges::stable_partition(::as_lvalue( | |
ranges::subrange(Iter(ap + 4), Sent(ap + 5))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 4); | |
CHECK(ap[4] == P{0, 1}); | |
} | |
@@ -364,7 +364,7 @@ test_range() | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + size))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap); | |
CHECK(ap[0] == P{0, 1}); | |
CHECK(ap[1] == P{0, 2}); | |
@@ -391,7 +391,7 @@ test_range() | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + size))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + size); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{1, 2}); | |
@@ -418,7 +418,7 @@ test_range() | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + size))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 1); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{0, 2}); | |
@@ -445,7 +445,7 @@ test_range() | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + size))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + 1); | |
CHECK(ap[0] == P{1, 2}); | |
CHECK(ap[1] == P{0, 1}); | |
@@ -472,7 +472,7 @@ test_range() | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + size))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + size - 1); | |
CHECK(ap[0] == P{1, 2}); | |
CHECK(ap[1] == P{3, 1}); | |
@@ -499,7 +499,7 @@ test_range() | |
std::size_t size = ranges::size(ap); | |
Iter r = ranges::stable_partition( | |
::as_lvalue(ranges::subrange(Iter(ap), Sent(ap + size))), | |
- odd_first()); | |
+ odd_first()).end(); | |
CHECK(base(r) == ap + size - 1); | |
CHECK(ap[0] == P{1, 1}); | |
CHECK(ap[1] == P{1, 2}); | |
@@ -544,7 +544,7 @@ test_move_only() | |
const unsigned size = 5; | |
move_only array[size] = {1, 2, 3, 4, 5}; | |
Iter r = ranges::stable_partition(Iter(array), Iter(array + size), is_odd{}, | |
- &move_only::i); | |
+ &move_only::i).end(); | |
CHECK(base(r) == array + 3); | |
CHECK(array[0].i == 1); | |
CHECK(array[1].i == 3); | |
@@ -587,7 +587,7 @@ TEST_CASE("alg.stable_partition") | |
using P = std::pair<int, int>; | |
{ // check mixed | |
S ap[] = { {{0, 1}}, {{0, 2}}, {{1, 1}}, {{1, 2}}, {{2, 1}}, {{2, 2}}, {{3, 1}}, {{3, 2}}, {{4, 1}}, {{4, 2}} }; | |
- S* r = ranges::stable_partition(ap, odd_first(), &S::p); | |
+ S* r = ranges::stable_partition(ap, odd_first(), &S::p).end(); | |
CHECK(r == ap + 4); | |
CHECK(ap[0].p == P{1, 1}); | |
CHECK(ap[1].p == P{1, 2}); | |
@@ -624,7 +624,7 @@ TEST_CASE("alg.stable_partition") | |
int some_ints[] = {1, 0}; | |
auto first = some_ints + 0, last = some_ints + 2; | |
auto even = [](int i) { return i % 2 == 0; }; | |
- ranges::stable_partition(first, last, even); | |
+ ranges::stable_partition(first, last, even).end(); | |
CHECK(std::is_partitioned(first, last, even)); | |
} | |
} | |
diff --git a/test/algorithm/unique.cpp b/test/algorithm/unique.cpp | |
index 0553183..5ed6133 100644 | |
--- a/test/algorithm/unique.cpp | |
+++ b/test/algorithm/unique.cpp | |
@@ -73,14 +73,14 @@ void test() | |
{ | |
int a[] = {0}; | |
const unsigned sa = sizeof(a) / sizeof(a[0]); | |
- auto r = Fun{}(a, a + sa); | |
+ auto r = Fun{}(a, a + sa).end(); | |
CHECK(r == It(a + sa)); | |
CHECK(a[0] == 0); | |
} | |
{ | |
int a[] = {0, 1}; | |
const unsigned sa = sizeof(a) / sizeof(a[0]); | |
- auto r = Fun{}(a, a + sa); | |
+ auto r = Fun{}(a, a + sa).end(); | |
CHECK(r == It(a + sa)); | |
CHECK(a[0] == 0); | |
CHECK(a[1] == 1); | |
@@ -88,14 +88,14 @@ void test() | |
{ | |
int a[] = {0, 0}; | |
const unsigned sa = sizeof(a) / sizeof(a[0]); | |
- auto r = Fun{}(a, a + sa); | |
+ auto r = Fun{}(a, a + sa).end(); | |
CHECK(r == It(a + 1)); | |
CHECK(a[0] == 0); | |
} | |
{ | |
int a[] = {0, 0, 1}; | |
const unsigned sa = sizeof(a) / sizeof(a[0]); | |
- auto r = Fun{}(a, a + sa); | |
+ auto r = Fun{}(a, a + sa).end(); | |
CHECK(r == It(a + 2)); | |
CHECK(a[0] == 0); | |
CHECK(a[1] == 1); | |
@@ -103,7 +103,7 @@ void test() | |
{ | |
int a[] = {0, 0, 1, 0}; | |
const unsigned sa = sizeof(a) / sizeof(a[0]); | |
- auto r = Fun{}(a, a + sa); | |
+ auto r = Fun{}(a, a + sa).end(); | |
CHECK(r == It(a + 3)); | |
CHECK(a[0] == 0); | |
CHECK(a[1] == 1); | |
@@ -112,7 +112,7 @@ void test() | |
{ | |
int a[] = {0, 0, 1, 1}; | |
const unsigned sa = sizeof(a) / sizeof(a[0]); | |
- auto r = Fun{}(a, a + sa); | |
+ auto r = Fun{}(a, a + sa).end(); | |
CHECK(r == It(a + 2)); | |
CHECK(a[0] == 0); | |
CHECK(a[1] == 1); | |
@@ -120,7 +120,7 @@ void test() | |
{ | |
int a[] = {0, 1, 1}; | |
const unsigned sa = sizeof(a) / sizeof(a[0]); | |
- auto r = Fun{}(a, a + sa); | |
+ auto r = Fun{}(a, a + sa).end(); | |
CHECK(r == It(a + 2)); | |
CHECK(a[0] == 0); | |
CHECK(a[1] == 1); | |
@@ -128,7 +128,7 @@ void test() | |
{ | |
int a[] = {0, 1, 1, 1, 2, 2, 2}; | |
const unsigned sa = sizeof(a) / sizeof(a[0]); | |
- auto r = Fun{}(a, a + sa); | |
+ auto r = Fun{}(a, a + sa).end(); | |
CHECK(r == It(a + 3)); | |
CHECK(a[0] == 0); | |
CHECK(a[1] == 1); | |
diff --git a/test/basic_algorithm/modifying_seq_ops.cpp b/test/basic_algorithm/modifying_seq_ops.cpp | |
index e67e633..d1abd8f 100644 | |
--- a/test/basic_algorithm/modifying_seq_ops.cpp | |
+++ b/test/basic_algorithm/modifying_seq_ops.cpp | |
@@ -558,8 +558,9 @@ TEST_CASE("alg.basic.unique") | |
std::vector<int> vec{1, 2, 2, 3, 3, 3, 4, 4}; | |
SECTION("with iterators") { | |
- const auto it = rng::unique(vec.begin(), vec.end()); | |
- REQUIRE(it == vec.begin() + 4); | |
+ const auto sub_range = rng::unique(vec.begin(), vec.end()); | |
+ REQUIRE(sub_range.begin() == vec.begin()); | |
+ REQUIRE(sub_range.end() == vec.begin() + 4); | |
REQUIRE(vec[0] == 1); | |
REQUIRE(vec[1] == 2); | |
REQUIRE(vec[2] == 3); | |
@@ -567,8 +568,9 @@ TEST_CASE("alg.basic.unique") | |
} | |
SECTION("with range") { | |
- const auto it = rng::unique(vec); | |
- REQUIRE(it == vec.begin() + 4); | |
+ const auto sub_range = rng::unique(vec); | |
+ REQUIRE(sub_range.begin() == vec.begin()); | |
+ REQUIRE(sub_range.end() == vec.begin() + 4); | |
REQUIRE(vec[0] == 1); | |
REQUIRE(vec[1] == 2); | |
REQUIRE(vec[2] == 3); | |
@@ -581,8 +583,9 @@ TEST_CASE("alg.basic.unique (with predicate)") | |
std::vector<int> vec{1, 2, 2, 3, 3, 3, 4, 4}; | |
SECTION("with iterators") { | |
- const auto it = rng::unique(vec.begin(), vec.end(), std::equal_to<>{}); | |
- REQUIRE(it == vec.begin() + 4); | |
+ const auto sub_range = rng::unique(vec.begin(), vec.end(), std::equal_to<>{}); | |
+ REQUIRE(sub_range.begin() == vec.begin()); | |
+ REQUIRE(sub_range.end() == vec.begin() + 4); | |
REQUIRE(vec[0] == 1); | |
REQUIRE(vec[1] == 2); | |
REQUIRE(vec[2] == 3); | |
@@ -590,8 +593,9 @@ TEST_CASE("alg.basic.unique (with predicate)") | |
} | |
SECTION("with range") { | |
- const auto it = rng::unique(vec, std::equal_to<>{}); | |
- REQUIRE(it == vec.begin() + 4); | |
+ const auto sub_range = rng::unique(vec, std::equal_to<>{}); | |
+ REQUIRE(sub_range.begin() == vec.begin()); | |
+ REQUIRE(sub_range.end() == vec.begin() + 4); | |
REQUIRE(vec[0] == 1); | |
REQUIRE(vec[1] == 2); | |
REQUIRE(vec[2] == 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment