
Hartmut,
Why not allow to convert between different string types?
Yes, I believe that is a very sensible question. In fact, I've tightened up the type checks for the implemented boost::string::convert() to minimize possible signature clashes with/of further extensions (via specializations/oveloads). In the current form boost::string::convert() is essentially a replacement for lexical_cast with added forrmatting, locale, etc. support. To add, say, u8string<->wstring conversion support we'll need overloads std::wstring convert(std::u8string) std::u8string convert(std::wstring) added.
Possible applications:
- std::string <--> std::wstring or similar (based on a future Boost.Unicode library)
I am not sure we can do std::string <-> std::wstring unless we know what std::string represents (currently it can be UTF8 or MBCS). If, with the introduction of std::u8string, std::string is guaranteed to be MBCS, then I guess we can have std::string <-> std::wstring as well.
- conversion between different symbol (character) sets
Currently convert() heavily relies on supplied types. Are we going to have distinct types for different symbol (character) sets? If not, then we might move forward as I've done for the throwing behavior (i.e. run-time configuration vs. compile-time configuration): int i = boost::string::convert(str, -1) >> boost::throw_t(); to pass a clue/directive what to do. Similarly we might do string new_set_str = boost::string::convert(old_set_str) >> new_set_directive(); Just thinking out loud. Does it look anywhere close to what you had in mind? V. P.S. Thank you for your Spirit conversion snippet another day. Appreciated.