#include <map>
int main( )
{
// Comparison lambda (see https://e...content-available-to-author-only...e.com/w/cpp/container/map/map).
auto comp = [ ] ( int a, int b) { return b < a; } ;
// This compiles.
std:: map < int , int > m1 { { 5 , 6 } , { 3 , 4 } , { 1 , 2 } } ;
// This also compiles.
std:: map < int , int , decltype( comp) > m2( comp) ;
// This doesn't compile (error: expected ‘}’ at end of input).
std:: map < int , int , decltype( comp) > m3( comp) { { 5 , 6 } , { 3 , 4 } , { 1 , 2 } } ;
return 0 ;
}
I2luY2x1ZGUgPG1hcD4KCmludCBtYWluKCkKewoJLy8gQ29tcGFyaXNvbiBsYW1iZGEgKHNlZSBodHRwczovL2UuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLmUuY29tL3cvY3BwL2NvbnRhaW5lci9tYXAvbWFwKS4KICAgIGF1dG8gY29tcCA9IFtdKGludCBhLCBpbnQgYikgeyByZXR1cm4gYiA8IGE7IH07CgoJLy8gVGhpcyBjb21waWxlcy4KICAgIHN0ZDo6bWFwPGludCwgaW50PiBtMSB7ezUsIDZ9LCB7MywgNH0sIHsxLCAyfX07CgogICAgLy8gVGhpcyBhbHNvIGNvbXBpbGVzLgogICAgc3RkOjptYXA8aW50LCBpbnQsIGRlY2x0eXBlKGNvbXApPiBtMihjb21wKTsKCgkvLyBUaGlzIGRvZXNuJ3QgY29tcGlsZSAoZXJyb3I6IGV4cGVjdGVkIOKAmH3igJkgYXQgZW5kIG9mIGlucHV0KS4KICAgIHN0ZDo6bWFwPGludCwgaW50LCBkZWNsdHlwZShjb21wKT4gbTMoY29tcCkge3s1LCA2fSwgezMsIDR9LCB7MSwgMn19OwoKICAgIHJldHVybiAwOwp9
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:15:49: error: expected ‘,’ or ‘;’ before ‘{’ token
std::map<int, int, decltype(comp)> m3(comp) {{5, 6}, {3, 4}, {1, 2}};
^
prog.cpp:18:1: error: expected ‘}’ at end of input
}
^
stdout