Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::variant<A,B> v = ...;
- std::visit([&v](auto& e){
- if constexpr (std::is_same_v<std::remove_reference_t<decltype(e)>,A>)
- e.some_modifying_operation_on_A();
- else {
- int i = e.some_accessor_of_B();
- v = some_function_returning_A(i);
- }
- }, v);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement