I'm declaring a map of string to a pair of pairs as follow:
std::map<std::wstring,
std::pair<std::pair<long, long>,
std::pair<long, long>>> reference;
And I initialize it as:
reference.insert(L"First",
std::pair<std::pair<long, long>,
std::pair<long, long>>(std::pair<long, long>(-1, -1),
std::pair<long, long>(0, 0)));
However, Visual C++ gives me the error "C2664, No constructor could take the source type, or constructor overload resolution was ambiguous".
I'm new to using templates and STL and I can't tell what I'm doing wrong.
The >>>
can not be parsed correctly (unless you have a C++0x compiler).
Change to > > >
This:
reference.insert("First",
Should be:
reference.insert(L"First",
^^^
Also there is a utility function to make the construction of pairs easier:
std::pair<std::pair<long, long>, std::pair<long, long>>(std::pair<long, long>(-1, -1), std::pair<long, long>(0, 0))
Can be:
std::make_pair(std::make_pair(-1L,-1L),std::make_pair(0L,0L))
Try this:
reference[L"First"]
= std::make_pair(std::make_pair(-1L,-1L),std::make_pair(0L,0L));
C++ gets confused by the consecutive ">" when you close the template as it interprets that as the shift operator.
Add spaces between the closing templates, change >>> to > > >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With