Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine the lambda of visitor #4

Open
erakis opened this issue Mar 12, 2018 · 1 comment
Open

Combine the lambda of visitor #4

erakis opened this issue Mar 12, 2018 · 1 comment

Comments

@erakis
Copy link

erakis commented Mar 12, 2018

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);
        // ...
    }
}
@cbeck88
Copy link
Owner

cbeck88 commented Dec 3, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants