jeudi 18 octobre 2018

What are curly braces in hash function?

In C++11, it is possible to get a hashed value for a string variable as follows:

std::size_t h1 = std::hash<std::string>{}("Some_String");

It is clean and simple. However, I have two questions:

  1. Why do we need the curly braces here?
  2. Is it possible to escape using the braces?

Aucun commentaire:

Enregistrer un commentaire