I am trying to make a variable with the data type std::map<char, wchar_t>
in C++. When I try this, Visual Studio gives this build error:
C2440 'initializing': cannot convert from 'initializer list' to 'std::map<char,wchar_t,std::less<char>,std::allocator<std::pair<const char,wchar_t>>>'
The same error also occurs when wchar_t
is the key data type and char
is the value data type.
You can replicate this error by running the following code:
const std::map<char, wchar_t> UNICODE_MAP = {
{ 'X', L"█" },
{ 'G', L"▓" },
{ 'O', L"ᗣ" },
{ 'P', L"ᗤ" }
};
How would I make a map with the key as a char
and the value as a wchar_t
data type?