Skip to content

Update lambdas.md #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docs/cpp/lambdas.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,19 @@ A strong reason to use generic lambdas is for visiting syntax.

```cpp
boost::variant<int, double> value;
apply_visitor(value, [&](auto&& e){
std::cout << e;
});
boost::apply_visitor(
[&](auto&& e){
std::cout << e;
},
value
);

```

Here we are visiting in a polymorphic manner; but in other contexts, the names of the type we are passing isn't interesting:

```cpp
mutex_wrapped<std::ostream&> os = std::cout;
mutex_wrapped<std::ostream&> os(std::cout);
os.write([&](auto&& os){
os << "hello world\n";
});
Expand Down