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

Compile error on C++14 #48

Open
soroush opened this issue Mar 14, 2023 · 2 comments
Open

Compile error on C++14 #48

soroush opened this issue Mar 14, 2023 · 2 comments

Comments

@soroush
Copy link

soroush commented Mar 14, 2023

Hi

The following code does not compile using MSVC 142 (19.35.32215 from VS 2022) using C++14 standard

#include <iostream>
#include "variant.hpp"

int main() {
    std::pair<std::string, nonstd::variant<std::string>> y2 = {"a", "b"};
}

It hits the error C3445: copy-list-initialization of 'std::pair<std::string, nonstd::blah>... which we assume is because in our setup, this is observed as false:

std::is_convertible<const char*, nonstd::variant<std::string>>::value

While the same for std::variant evaluates to true. This then makes std::pair constructor to be explicit which in turn removes the possibility of using a wide range of valid codes like this:

    using foo = nonstd::variant<std::string>;
    using bar = std::map<std::string, foo>;
    auto zoo = bar{{"hello", "world"}};
@martinmoene
Copy link
Owner

Thank you for making me aware of this.
Takes some staring at it...

@soroush
Copy link
Author

soroush commented Jul 20, 2023

Any workarounds yet?

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