Topic: Why did string::string(char c, size_t rep =1) go away?
Author: Matt Seitz <mseitz@meridian-data.com>
Date: 1996/11/23 Raw View
Why was string::string(char c, size_t rep =1) changed to
string::string(size_t rep, char c)? Now to initialize a string with a
single char c I have to either write
string foo(1, c);
or
string foo;
foo += c;
In the first case it is easy to reverse the parameters, especially if
you're used to the old constructor. If you do reverse the parameters,
Visual C++ will not issue any warnings.
The second case eliminates the chance of mixing up the parameters, but
at the cost of requiring two statements instead of just one.
It seems that the older constructor form was easier and less error prone
for the case of initializing a string with a single char. So why did
they get rid of it?
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]