ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
[boost] Re: [optional] update
by Fernando Cacciola other posts by this author
Sep 17 2003 4:05PM messages near this date
[boost] Re: Re: [optional] update | Re: [boost] [optional] update
Mat Marcus <mmarcus-boost@[...].org>  wrote in message
news:318546735.1063785477@[...]..
> 
> 
>  --On Tuesday, September 09, 2003 6:43 PM -0300 Fernando Cacciola
>  <fernando_cacciola@[...].com> wrote:
> 
>  > Hi boosters,
>  >
>  > Following the suggestions that had been made since Optional's
>  > acceptance I've updated the library.
>  > I will upload the new version on main CVS tomorrow noon unless
>  > someone objects.
> 
>  Thanks a lot for updating optional! The new version really simplifies
>  my optional usage to the point where I'm willing to commit to it in my
>  current project.
> 
Great!

Thanks for your feedback!

>  [snip]
> 
>  This is rather convenient. It is a little bit less convenient to
>  construct the end out_edge_iterator. In my case end is represented by
>  an iterator with uninitialized optional state. Here I apparently have
>  to write:
> 
>  out_edge_iterator i(optional<out_edge_iterator>());
>  file://longer in its fully qualified glory
> 
I think the line above should probably be:

out_edge_iterator i(optional<edge_descriptor> ());

>  I imagine that it could be useful to have something like a universal
>  'none' object that could be passed to functions expecting optionals. I
>  would expect its effect to be the same as passing the anonymously
>  constructed optional in the line of code directly above. That is I
>  would like to write:
> 
>  out_edge_iterator end(none); file://optional::none?
> 
Well, something like this can be done, though I wonder why couldn't
you just use the default constructor as in:

out_edge_iterator end;

which is the cannonical way to introduce an uninitialized optional<> .

> 
>     * Safe optional<bool>'s as tri-bools would be quite useful to me. I
>  personally would sacrifice the convenience of testing without using
>  is_initialized() to gain tri-bools but I don't want to cover old
>  territory. Perhaps there's some other way of making optional<bool>'s
>  safer to use. What would you think of, say, using enable_if (or better
>  disable_if) to disable implicit bool conversion and operator! for when
>  T == bool (or when T already is_convertible to bool)?
> 
I decided not to treat optional<bool>  specially since as Doug just said
there is boost::tribool.
In order to use optional "safely" and uniformly in the presence of
[T=possibly bool] all you have to do is not to use the safe_bool feature.
For instance, you can consistently use the double-bang idiom:

if ( !!opt ) ....

HTH

Fernando Cacciola




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Fernando Cacciola
Fernando Cacciola
Fernando Cacciola
Mat Marcus

Guillaume Melquiond

Mat Marcus
Eric Friedman
Hamish Mackenzie
Fernando Cacciola
Eric Friedman
Markus Werle
Hamish Mackenzie
Mat Marcus
Mat Marcus
Hamish Mackenzie
Fernando Cacciola
Hamish Mackenzie
Fernando Cacciola
David Abrahams
Eric Friedman
Fernando Cacciola
Hamish Mackenzie
Russell Hind
Hamish Mackenzie
Joel de Guzman

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved