|
Boost : |
From: Bo Persson (bop2_at_[hidden])
Date: 2003-07-21 16:56:37
"Rodolfo Lima" <rodolfo_at_[hidden]> skrev i meddelandet
news:bfgrsv$bgt$1_at_main.gmane.org...
> I had some problems with lexical_cast and not using wchar_t as a
built-in
> type. For instance...
>
> std::stringstream ss;
> ss << boost::lexical_cast<unsigned short>("23");
>
> lexical_cast would return a wstring, and a compile failure, because
> internally there is a the template that matches unsigned short as
wchar_t,
> which makes lexical_cast return a wstring. Or something like this.
The fact
> is that this example gives an cryptic compiler error (it was for
me):
>
> boost\lexical_cast.hpp(147) : error C2679: binary '<<' : no operator
found
> which takes a right-hand operand of type 'const
>
boost::token_iterator_generator<TokenizerFunc,Iterator,Type>::value_ty
pe'
> (or there is no acceptable conversion)
>
> Maybe to avoid this kind of compiler error message, there's such
requirement
> of wchar_t being an native type.
There *is* such a requirement for VC7.1 ostream, which explicitly
says:
/* Note that if your stream is wchar_t, and you are not using
native wchar_t
Then this operation will be unavailable as there is an
explicit
specialisation further down this file that is designed to
treat an
unsigned short as a character.
If you wish to read or write unsigned shorts to wchar_t
streams, you should
consider making wchar_t a native type by turning on
/Zc:wchar_t
*/
_Myt& operator<<(unsigned short _Val)
{ ...
Bo Persson
bop2_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk