
2012/4/12 Mathias Gaunard <mathias.gaunard@ens-lyon.org>:
On 12/04/12 14:24, Antony Polukhin wrote:
Current implementation is simple, and user only required to provide stream operators<< and>> to work with it.
Yes, but apparently, that doesn't work with user-defined wide string types.
Having to implement three traits that each must provide conversion facilities to all of char*, wchar_t*, char16_t* and char32_t* seems a bit much.
Surely there must be a simpler solution.
First (and simpliest) solution is: leave everything as is. If lexical_cast fails - use wstream. Second solution: allow user to specialize stream_char<>. Other solutions will add much more complications, introduce ugly conversion API. Specializing stream_char<> does not solve all the problems. Noexcept version of lexical cast, fast user defined conversions are still impossible. There is one more solution: determinate stream_char<>::type for UserType using lots of meta-programming. For that solution following meta-functions required: has_output_stream_operator_for_char<UserType>::value has_output_stream_operator_for_wchar_t<UserType>::value has_output_stream_operator_for_char16_t<UserType>::value has_output_stream_operator_for_char32_t<UserType>::value Is there any ideas, how that can be done in a *portable* way? -- Best regards, Antony Polukhin