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

[BUG] Cannot initialize a std::unordered_map with literals #1343

Open
threeifbyair opened this issue Nov 29, 2024 · 1 comment · May be fixed by #927
Open

[BUG] Cannot initialize a std::unordered_map with literals #1343

threeifbyair opened this issue Nov 29, 2024 · 1 comment · May be fixed by #927
Labels
bug Something isn't working

Comments

@threeifbyair
Copy link

Describe the bug
There is no way to use literals to initialize a std::unordered_map. The parentheses are not translated into braces and hence are treated as a pair of comma-separated values by C++1, ignoring the first value.

To Reproduce
bar : std::unordered_map<int, std::string> = ( ( 42, "hello" ), ( 43, "world" ) );

translates to

std::unordered_map<int,std::string> bar {(42, "hello"), (43, "world")};

https://cpp2.godbolt.org/z/Gqh9brrdE (this includes some more cases)

@threeifbyair threeifbyair added the bug Something isn't working label Nov 29, 2024
@JohelEGP
Copy link
Contributor

Relates to #542 and its linked issues.

@JohelEGP JohelEGP linked a pull request Nov 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants