Skip to content
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