I got a strange beaviour in my program.
I wrote a test which always failed.
While debugging i saw something i don’t understand:
I got some multiple Constructors, but this one gets always called if i pass unicode via _T():
IsNullable(bool isNullable)
: m_bIsNullabe(isNullable), Flag(eNullAllowed)
{};
And here’s my way of calling the constructor:
... = new IsNullable(_T("N"));
The strange thing is that the bool Constructor above gets always called…
Why is that so? I would be really pleased if someone got a clue!
Greeds,
Clemens
EDIT:
This Constructor should get called:
IsNullable(wchar_t isNullable)
: Flag(eNullAllowed)
{...};
The constructor that you want to be called takes a
wchar_tcharacter, not a pointer to a wide string. Call it as:Note that I’m not using the
_Tmacro because your constructor argument type iswchar_tand it is not predicated on whether theUNICODEsymbol is defined. So there’s no need for that macro in this case.The reason the other constructor is being called is because the string literal, of type
const wchar_t[2](assuming the_Tmacro expands toL"N"), decays to aconst wchar_t *which is then implicitly converted to abool.