From b42150b922f2b65560065f7688505deacb58ac2d Mon Sep 17 00:00:00 2001 From: RogueNemo <129790473+RogueNemo@users.noreply.github.com> Date: Thu, 11 May 2023 14:49:21 -0500 Subject: [PATCH] Update lambdas.md https://stackoverflow.com/questions/76223960/what-is-mutex-wrapped/ --- docs/cpp/lambdas.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/cpp/lambdas.md b/docs/cpp/lambdas.md index 5cc62dc2..9af750f0 100644 --- a/docs/cpp/lambdas.md +++ b/docs/cpp/lambdas.md @@ -508,16 +508,19 @@ A strong reason to use generic lambdas is for visiting syntax. ```cpp boost::variant 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 os = std::cout; +mutex_wrapped os(std::cout); os.write([&](auto&& os){ os << "hello world\n"; });