cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

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

Open threeifbyair opened this issue 1 year ago • 1 comments

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 avatar Nov 29 '24 03:11 threeifbyair