Skip to content

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

Open
@threeifbyair

Description

@threeifbyair

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions