C++ Logo

std-discussion

Advanced search

Re: std::variant - going from Alternative& to the enclosing variant&

From: Roman Odaisky <roma_at_[hidden]>
Date: Sun, 23 Aug 2020 03:17:54 +0300
On Friday, 21 August 2020 17:06:47 EEST Victor Khomenko via Std-Discussion
wrote:

> Problem: How to change the value of a variant from within a visitor?

Sorry if I’m missing something, but can’t you simply pass the variant as
another parameter with something like this?

std::visit([&](auto&& value) {
    my_visitor(value, the_variant);
}, the_variant);

-- 
WBR
Roman.

Received on 2020-08-22 19:21:26