|
Boost Users : |
From: Richard (legalize+jeeves_at_[hidden])
Date: 2008-04-01 17:52:27
[Please do not mail me a copy of your followup]
boost-users_at_[hidden] spake the secret code
<loom.20080401T194410-421_at_[hidden]> thusly:
>I have a string class (tstring) which takes care of narrow <=> wide string
>conversions, and which provides operators for conversion to std::string and
>std::wstring:
>
> operator std::wstring &();
> operator std::string &();
> operator const std::wstring &() const;
> operator const std::string &() const;
I used to think that implicit conversions were great, until I read
"C++ Coding Standards: 101 Rules, Guidelines, and Best Practices" by
Sutter and Alexandrescu. Now I eschew implicit conversions and use an
explicit conversion where needed.
I know that doesn't really answer your question about why it used to
work and why it doesn't anymore, but had you written the code with an
explicit conversion to std::string, it would have worked before and
would still work now.
I guess that shows the wisdom of why implicit conversions should be
avoided...
-- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net