
On Wed, May 4, 2011 at 11:33 AM, Olaf van der Spek <ml@vdspek.org> wrote:
On Tue, May 3, 2011 at 8:52 PM, Olaf van der Spek <ml@vdspek.org> wrote:
On Tue, May 3, 2011 at 6:57 PM, Robert Jones <robertgbjones@gmail.com> wrote:
I'd prefer to see it return a boost::optional<T&>
What's the benefit?
Simply that the difficulty you're addressing is the possibility that
On Wed, May 4, 2011 at 9:37 AM, Robert Jones <robertgbjones@gmail.com> wrote: there's
no value to return. Boost.optional expresses that directly.
Returning NULL works just as well. Using a raw pointer also allows you to write string* ptr = find_ptr(). Using Boost Optional would make that longer.
You'd have to write optional<string> s = find_ptr(); //Now misnamed of course! Either way, at some point you'd have to check the value was usable before using it. - Rob.