|
|
Orchid Win7 v1 <voi### [at] devnull> wrote:
> On 14/05/2013 06:04 PM, Warp wrote:
> > When using the standard containers, one should know how they work and
> > what they are doing, in terms of efficiency. For example, passing them
> > by value eg. as function parameters is inefficient, and that should always
> > be done by reference, if possible.
> How about std::string? Presumably it's a bad idea to pass that by value
> either...
It depends on the implementation.
Since std::string is so ubiquitous, many standard library implementations
have optimizations that make copying them fast (some use short string
optimization, some use lazy copying...), but that's in no way a guarantee.
There's usually no reason to not to use a std::string reference if it
suffices. Only copy when you have to.
--
- Warp
Post a reply to this message
|
|