[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: object-model: Return by value, reference or pointer? (or something else?)

From: Steinar Bang <sb_at_dod.no>
Date: Fri, 15 Oct 2010 11:58:06 +0200

>>>>> Steinar Bang <sb_at_dod.no>:

>>>>> Philipp Marek <philipp.marek_at_linbit.com>:
>> It might be easier for callers if this did
>> if (isNull)
>> return "";
>> so that the value could just be used in printf() and similar without
>> explicit checking.

> If that was ok to do, one might as well represent a NULL with an empty
> string.

As I said in a different message in the thread, if you need NULL, I
think returning auto_ptr<string> is the simplest way that is both
standards compliant, won't leak memory, and doesn't force you to handle
object life cycle for the returned strings.
Received on 2010-10-15 11:58:55 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.