From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-12-01 18:07:53
>From: "Phil Nash" <phil.nash.lists_at_[hidden]>
> [Terje Slettebø]
> > Speaking of different character types, perhaps there could also be
> > for converting between strings of different character types, as well?
> > example:
> > std::string str=lexical_cast<std::string>(L"A wide character string");
> > std::wstring wstr=lexical_cast<std::wstring>("A character string");
> I have written something like this (actually it was a colleague that wrote
> the guts of it), which we called string_cast.
> As I say, although we tweaked it a little, the guts of it came from some
> other boost library somewhere, I just can't remember where OTTOMH.
> The string_cast code itself was very simply a template specialisation
> wrapper round ToNarrow and ToWide. I wrote it as a class in the end, to
> round the problem that MSVC 6 (which we needed it to work on too) had with
> template parameters you don't use in a function signature.
Well, lexical_cast also works for MSVC 6, so it appears that explicit
template parameter specification for function template works for it. So
can't it be done as shown above here, using the string_cast name?
> If we could get the locale based stuff working (we didn't have time to
> on it on our project) then maybe we could propose it?
Sounds good. One less thing for me to do. :)
Besides, this string conversion is I guess a little on the edge of what
lexical_cast is supposed to do, so a separate component could be better.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk