On Fri, Oct 15, 2010 at 8:06 AM, Hyrum K. Wright
<hyrum_wright_at_mail.utexas.edu> wrote:
> 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.)
Added something called ValidString in r1023863. Review welcome.
-Hyrum
Received on 2010-10-18 17:52:22 CEST