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