Initialize unordered_map in the initializer list

Use braces instead of the parentheses

class test {
 public:
    test()
      : map_{{23, 1345}, {43, -8745}} {}

 private:
   const std::unordered_map<long, long> map_;
 };

Use curly braces instead of the parentheses because if you use parentheses it's calling the constructor that best matches your arguments instead of the overloaded constructor with a parameter of type initializer_list.

Using parentheses and curly braces have the same effect until there's an overloaded constructor taking initializer_list type as a parameter. Then when you use curly braces, the compiler is going to bend over backwards to try to call that overloaded constructor.

for example:

Foo( 3 ) is calling Foo( int x ) constructor;
Foo{ 3 } is calling Foo( initializer_list<int> x ) constructor;

but if there's no Foo( initializer_list<int> x ) constructor

then Foo( 3 ) and Foo{ 3 } are both calling Foo( int x ) constructor.