
Vladimir Prus wrote:
Peter Dimov wrote:
The very same question arises with path/wpath:
path p( "foo") p /= wpath(L"bar");
We can avoid it by not defining a mixed operator/=, though.
Yes, but what if I need to do this? Then there should be some conversion function, and why that conversion function can't be called by mixed operator/=, then?
Because the library may not convert the way you want it to. Even if a wpath is convertible to a path, the converting constructor should probably be explicit. p /= wpath(L"bar"); seems fine at first sight, but it's actually an error; it should have been p /= "bar"; Without an implicit conversion, p /= path(wpath(L"bar")); the redundant conversions are much more evident. And to get back to the original question, p always stores a narrow path, so there is no ambiguity whether L"bar" needs to be narrowed, or "foo" is to be widened. There is a potential ambiguity with a mixed operator/, though, if one is provided. Which is why there shouldn't be a mixed operator/. ;-)