Skip to content

Commit

Permalink
Merge pull request Mq-b#7 from gandyli/main
Browse files Browse the repository at this point in the history
Create andyli.cpp
  • Loading branch information
Mq-b authored Aug 4, 2023
2 parents 04c177d + 83772f9 commit 17bec91
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/群友提交/第一题/andyli.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <algorithm>
#include <vector>
#include <functional>
#include <iostream>

template <typename R, typename F>
auto operator|(R&& r, F&& f) {
for (auto&& x: r)
f(x);
return r;
}
int main() {
std::vector v{1, 2, 3};
std::function f{[](const int& i) { std::cout << i << ' '; }};
auto f2 = [](int& i) { i *= i; };
v | f2 | f;
}

0 comments on commit 17bec91

Please sign in to comment.