Topic: Conversion charT -> basic_string: why not ?
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1997/05/08 Raw View
Why isn't there a conversion from charT to basic_string ? It seem
pretty safe (and would help me not to break too much code).
Ok everyone here hate implicit conversion, so after a sugestion
about making more code legal, here is a proposal to make more
code illegal:
string s (' ', 5); // five spaces
// call basic_string::basic_string(size_type n, charT c,
// const Allocator& a = Allocator());
Many compiler won't give a warning here (I think g++ sometimes
gives a warning, sometimes not). Detection at compile time is
absolutly trivial:
private:
basic_string::basic_string (charT, size_type,
const Allocator& = Allocator())
An error will result in access spec violation or ambiguity.
--
Valentin Bonnard
mailto:bonnardv@pratique.fr
http://www.pratique.fr/~bonnardv (Informations sur le C++ en Francais)
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]