template <class Body>
void foreach(Body&& body) const {
source_.foreach([&](Value value) {
- // NB: Argument not forwarded to avoid accidental move-construction
- if (pred_(value)) {
+ if (pred_(std::forward<Value>(value))) {
body(std::forward<Value>(value));
}
});
template <class Handler>
bool apply(Handler&& handler) const {
return source_.apply([&](Value value) -> bool {
- // NB: Argument not forwarded to avoid accidental move-construction
- if (pred_(value)) {
+ if (pred_(std::forward<Value>(value))) {
return handler(std::forward<Value>(value));
}
return true;
}
}
-TEST(Gen, FilterSink) {
- auto actual
- = seq(1, 2)
- | map([](int x) { return vector<int>{x}; })
- | filter([](vector<int> v) { return !v.empty(); })
- | as<vector>();
- EXPECT_FALSE(from(actual) | rconcat | isEmpty);
-}
-
TEST(Gen, Contains) {
{
auto gen =