Boost logo

Boost :

Subject: Re: [boost] [lexical_cast] char types and UDTs
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2012-04-12 12:14:51

2012/4/12 Mathias Gaunard <mathias.gaunard_at_[hidden]>:
> 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

There is one more solution: determinate stream_char<>::type for
UserType using lots of meta-programming. For that solution following
meta-functions required:

Is there any ideas, how that can be done in a *portable* way?

Best regards,
Antony Polukhin

Boost list run by bdawes at, gregod at, cpdaniel at, john at