I have a problem understanding why a certain implicit conversion is not working as I expect it. I have the following class
ref class ManagedWStringArrayWrapper
{
wchar_t** m_pointer;
public:
operator wchar_t**()
{
return m_pointer;
}
};
and I thought this would implicitly convert to const wchar_t ** as well – but it doesn’t. Can someone tell me why?
Conversion from
T**toT const**is not as intuitive as you might expect — in fact, it’s given as an example in the standard itself asconst-incorrect code.The example given is:
Study the above scenario for a while and it will become clear that this is not the same as a conversion
T*→T const*. Not at all!I asked the same question in a blog post, and the FAQ has an entry on it too.