On Fri, Jan 8, 2010 at 1:51 AM, Albert J. Wong (王重傑) <[email protected]>wrote:
> On Thu, Jan 7, 2010 at 2:46 PM, Darin Fisher <[email protected]> wrote: > >> >> On Thu, Jan 7, 2010 at 1:34 PM, Jeremy Orlow <[email protected]> wrote: >> >>> (As discussed during lunch...) Why not just do this in this case and >>> remove EmptyString() altogether? >>> >>> const std::string& MyClass::foo() const { >>> static std::string empty = EmptyString(); >>> return (everything == OK) ? member_string : empty; >>> } >>> >>> >> This is not thread safe. EmptyString() uses Singleton<T> to basically >> achieve the same thing in a thread safe manner. >> > > Is there something wrong with returning by copy, and relying on the > compiler > to execute a return value optimization? > > Do you volunteer to rewrite the compilers to implement said optimization? GCC, for one will not do so.
-- Chromium Developers mailing list: [email protected] View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev
