Re: Replacing a quote by a "\n" ...
On Nov 27, 6:25 pm, "Alf P. Steinbach" <al...@start.no> wrote:
[...]
Again, re optimization: std::string is not well suited for string
handling. It's not even well suited for passing strings around,
technically. But it's standard, and that's one great plus point, so
great that std::string is the default choice for that.
As a summary of std::string, this is actually pretty good. But
to be fair: std::string does define both the copy constructor
and an assignment operator---what else do you need for passing
strings around?
However, if optimization is required, consider some other
string class first, instead of fiddling with std::string-based
code.
More generally: don't use fundamental library types as part of
your application level abstraction. If your abstraction deals
with text, for example, don't use std::string for that text; use
some user defined class. A class which almost certainly uses
std::string in its implementation, at least until the profiler
says otherwise, but a class which defines very exactly the
interface you need. This is a good general rule, as it keeps
your options open. Use std::string directly, or a typedef to
std::string, and you're locked in; use a user defined class with
a narrower interface, and you can change the implementation in
any way that conforms to the interface.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34