Date/time class changes to handle extended date ranges
Guillaume Laurent
glaurent at telegraph-road.org
Mon Feb 20 07:18:22 GMT 2006
On Monday 20 February 2006 02:37, R.F. Pels wrote:
> On Monday 20 February 2006 00.42, Guillaume Laurent wrote:
> >
> > Uh, all string classes (std::string, QString, etc...) have conversions
> > for plain old char*.
>
> Tss! Not true. That it is true that basic_string<char> has
>
> basic_string<char>::basic_string(const char*);
> const char* c_str() const;
> const char* data() const;
>
> is because there is a one-on-one conversion possible from
> basic_string<char> to char* and vice-versa.
Except that a std::string doesn't consider \0 to be a terminator :
std::string truncS = "abcd";
truncS += char(0);
truncS += "efg";
cout << "truncS : " << truncS << endl;
cout << "truncS.c_str() : " << truncS.c_str() << endl;
prints :
abcdefg
abcd
so std::string DOES widen the contract, and there is no 1-1 conversion.
Likewise, QString has
const char * ascii () const
const char * latin1 () const
QCString utf8 () const
QCString local8Bit () const
none of which guarantee anything about what you'll obtain.
> Bah. That's BAD. BAD BAD BAD. Look at the boilerplate error checking
> example I gave.
I have, it's the kind of stuff we all have to write at one time or another.
Big deal.
--
Guillaume.
http://www.telegraph-road.org
More information about the kde-core-devel
mailing list