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?
std::shared_ptr<std::map<double, std::string>> foo = std::make_shared<std::map<double, std::string>>(std::initializer_list<std::map<double, std::string>::value_type>{{1000.0, s1}});
– Soullessstd::shared_ptr<std::map<double, std::string>> foo = std::make_shared<std::map<double, std::string>>(std::map<double, std::string>{{1000.0, s1}});
but still not nice – Soullessvalue_type
. I see its justtypedef pair<const Key, Type>
. Why do I need that? – Flagging