diff --git a/ostd/algorithm.hh b/ostd/algorithm.hh index 5c2d5d5..9b518ad 100644 --- a/ostd/algorithm.hh +++ b/ostd/algorithm.hh @@ -30,7 +30,7 @@ inline R partition(R range, U pred) { } template inline auto partition(F func) { - return [&func](auto &obj) mutable { return partition(obj, func); }; + return [&func](auto &obj) { return partition(obj, move(func)); }; } template @@ -42,9 +42,7 @@ inline bool is_partitioned(R range, P pred) { } template inline bool is_partitioned(F func) { - return [&func](auto &obj) mutable { - return is_partitioned(obj, move(func)); - }; + return [&func](auto &obj) { return is_partitioned(obj, move(func)); }; } /* sorting */ @@ -258,7 +256,7 @@ inline F for_each(R range, F func) { } template inline auto for_each(F func) { - return [&func](auto &obj) mutable { + return [&func](auto &obj) { for (; !obj.empty(); obj.pop_front()) func(obj.front()); return move(func); @@ -273,7 +271,7 @@ inline bool all_of(R range, P pred) { } template inline auto all_of(F func) { - return [&func](auto &obj) mutable { return all_of(obj, move(func)); }; + return [&func](auto &obj) { return all_of(obj, move(func)); }; } template @@ -284,7 +282,7 @@ inline bool any_of(R range, P pred) { } template inline auto any_of(F func) { - return [&func](auto &obj) mutable { return any_of(obj, move(func)); }; + return [&func](auto &obj) { return any_of(obj, move(func)); }; } template @@ -295,7 +293,7 @@ inline bool none_of(R range, P pred) { } template inline auto none_of(F func) { - return [&func](auto &obj) mutable { return none_of(obj, move(func)); }; + return [&func](auto &obj) { return none_of(obj, move(func)); }; } template @@ -337,7 +335,7 @@ inline R find_if(R range, P pred) { } template inline auto find_if(F func) { - return [&func](auto &obj) mutable { return find_if(obj, move(func)); }; + return [&func](auto &obj) { return find_if(obj, move(func)); }; } template @@ -349,7 +347,7 @@ inline R find_if_not(R range, P pred) { } template inline auto find_if_not(F func) { - return [&func](auto &obj) mutable { return find_if_not(obj, move(func)); }; + return [&func](auto &obj) { return find_if_not(obj, move(func)); }; } template @@ -393,7 +391,7 @@ inline RangeSize count_if(R range, P pred) { } template inline auto count_if(F func) { - return [&func](auto &obj) mutable { return count_if(obj, move(func)); }; + return [&func](auto &obj) { return count_if(obj, move(func)); }; } template @@ -406,7 +404,7 @@ inline RangeSize count_if_not(R range, P pred) { } template inline auto count_if_not(F func) { - return [&func](auto &obj) mutable { return count_if_not(obj, move(func)); }; + return [&func](auto &obj) { return count_if_not(obj, move(func)); }; } template @@ -420,7 +418,7 @@ inline bool equal(R range1, R range2) { } template inline bool equal(R range) { - return [&range](auto &obj) mutable { return equal(obj, move(range)); }; + return [&range](auto &obj) { return equal(obj, move(range)); }; } template @@ -429,7 +427,7 @@ R slice_until(R range1, R range2) { } template inline auto slice_until(R range) { - return [&range](auto &obj) mutable { return slice_until(obj, move(range)); }; + return [&range](auto &obj) { return slice_until(obj, move(range)); }; } /* algos that modify ranges or work with output ranges */ @@ -523,7 +521,7 @@ inline T foldl(R range, T init, F func) { } template inline auto foldl(T init) { - return [&init](auto &obj) mutable { return foldl(obj, move(init)); }; + return [&init](auto &obj) { return foldl(obj, move(init)); }; } template @@ -541,7 +539,7 @@ inline T foldr(R range, T init, F func) { } template inline auto foldr(T init) { - return [&init](auto &obj) mutable { return foldr(obj, move(init)); }; + return [&init](auto &obj) { return foldr(obj, move(init)); }; } template @@ -633,7 +631,7 @@ inline MapRange> map(R range, F func) { } template inline auto map(F func) { - return [&func](auto &obj) mutable { return map(obj, move(func)); }; + return [&func](auto &obj) { return map(obj, move(func)); }; } template @@ -706,7 +704,7 @@ inline FilterRange> filter(R range, P pred) { } template inline auto filter(F func) { - return [&func](auto &obj) mutable { return filter(obj, move(func)); }; + return [&func](auto &obj) { return filter(obj, move(func)); }; } } /* namespace ostd */ diff --git a/ostd/range.hh b/ostd/range.hh index 113096e..fb1124a 100644 --- a/ostd/range.hh +++ b/ostd/range.hh @@ -580,7 +580,7 @@ template>> -inline auto operator|(const R &range, F &&func) -> decltype(func(range)) { +inline auto operator|(const R &range, F func) { return func(range); } @@ -606,15 +606,14 @@ inline auto chunks(T n) { return [n](auto &obj) { return obj.chunks(n); }; } -/* TODO: can't use generalized captures on packs so gotta workaround */ template inline auto join(R1 r1, R ...rr) { - return [=](auto &obj) mutable { return obj.join(move(r1), move(rr)...); }; + return [&](auto &obj) { return obj.join(move(r1), move(rr)...); }; } template inline auto zip(R1 r1, R ...rr) { - return [=](auto &obj) mutable { return obj.zip(move(r1), move(rr)...); }; + return [&](auto &obj) { return obj.zip(move(r1), move(rr)...); }; } template