mercredi 6 avril 2016

Initialising std::shared_ptr

I have the following shared_ptr to a map:

std::shared_ptr<std::map<double, std::string>>

and I would like to initialise it using braced-init. Is it possible?

I've tried:

std::string s1("temp");
std::shared_ptr<std::map<double, std::string>> foo = std::make_shared<std::map<double, std::string>>(1000.0, s1);

but that gives the following error when compiled using Xcode 6.3:

/usr/include/c++/v1/map:853:14: Candidate constructor not viable: no known conversion from 'double' to 'const key_compare' (aka 'const std::__1::less<double>') for 1st argument

I've tried other variations of the first parameter (1000.0) without success.

Can anyone help?

Aucun commentaire:

Enregistrer un commentaire