POV-Ray : Newsgroups : povray.off-topic : Adventures with C++ : Re: Adventures with C++ Server Time
28 Jul 2024 18:15:40 EDT (-0400)
  Re: Adventures with C++  
From: Warp
Date: 14 May 2013 15:46:09
Message: <51929480@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.