-
Notifications
You must be signed in to change notification settings - Fork 26
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
Visitors can't return references, but they can with std::variant #39
Comments
Hi @ligfx , Thanks for your message. I think a relevant remark related to C++11 and later is No perfect forwarding here in order to simplify code. Used wrong selection of nonstd::variant:
|
Hi @martinmoene, I don't think perfect forwarding is related to this. There are two places in the code that explicitly try to default construct the return type, regardless of which version of C++: variant-lite/include/nonstd/variant.hpp Line 1922 in a0a1be0
variant-lite/include/nonstd/variant.hpp Line 2109 in a0a1be0
When the return type is a const reference, it can't be default constructed. Since a visitor is required to match all possible alternatives, that code should never be called, but the compiler doesn't like it anyways. What do you think about changing those lines to |
Thanks @ligfx , will look into this later. |
Great, thanks! |
Example of the issue:
The STL version of variant compiles and works. nonstd::variant throws a compile error:
The text was updated successfully, but these errors were encountered: