Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2006-04-11 08:48:25


David Abrahams wrote:
> "Reece Dunn" <msclrhd_at_[hidden]> writes:
>
> > Drawing influence from Python, I suggest that the non-throwing version look like:
> >
> > std::pair<T,bool> string_to<T>(x)
> >
> > allowing:
> >
> > fn( string_to<Object>(object).first );
>
> How does that draw influence from Python?

I was refering to multiple-valued returns. For example:

   def string_to( object ):
      return object, was_there_an_error

   obj, err = string_to( ... )

> That interface doesn't allow for types that can't be default
> constructed.
>
> optional<T> string_to<T>(x)
>
> seems more likely.

That does look better. So in that case, an error would be indicated by the optional<T> return containing null.

- Reece
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk