[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: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: Fri, 15 Oct 2010 08:06:10 -0500

On Fri, Oct 15, 2010 at 4:35 AM, Branko Čibej <brane_at_xbc.nu> wrote:
>  On 14.10.2010 20:39, Hyrum K. Wright wrote:
>> The following is a somewhat naïve implementation, but does it jive
>> with your suggestion?
>
> Roughly yes, see the other comment.
> On reflection, though, I like the suggestion of returning an
> std::pair<std::string, bool>. Make a typedef of that so that users can
> declare return-value variables, and use it where it's absolutely
> necessary to know that it's not an empty string but a null string. Saves
> a lot of trouble with the string subclassing, too. And better than
> pulling in 90% of boost just to get a poor-man's replacement for null
> references.

Yeah, after that little implementation exercise, and hearing here all
the nuances of subclassing std::string, I'm leaning in this direction
as well. Having a separate NullableString type would also help folks
know which strings are guaranteed to have values and which ones are
"optional" via the API. (I hope our C docs point this out explicitly,
too.)

-Hyrum
Received on 2010-10-15 15:06: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.