strict-variant
strict-variant copied to clipboard
Combine the lambda of visitor
Hi,
Would you mine adding a make_visitor
as seen on this page to allow using lambada with multiple type handling ?
Ref: https://bitbashing.io/std-visit.html
Ex :
[](auto& arg) {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, string>) {
printf("string: %s\n", arg.c_str());
// ...
}
else if constexpr (std::is_same_v<T, int>) {
printf("integer: %d\n", arg);
// ...
}
else if constexpr (std::is_same_v<T, bool>) {
printf("bool: %d\n", arg);
// ...
}
}
Yeah I can do that, but I think it's got some other names also:
https://arne-mertz.de/2018/05/overload-build-a-variant-visitor-on-the-fly/#The_stdoverload_proposal
make_visitor
is not a bad one though and it won't conflict with std
I guess
Sorry I missed this issue until now