Boost logo

Boost :

From: Maarten Kronenburg (M.Kronenburg_at_[hidden])
Date: 2006-05-25 18:50:28


Pedro,
Thanks, I see it now in [lib.util.smartptr.shared.obs].
Thanks to you all for pointing me to this
and solving my bool conversion problem.
So if( x ) should be possible for integer x,
and I will include this in my document,
and test it for a few compilers.
Regards, Maarten.

"Pedro Lamarão" <pedro.lamarao_at_[hidden]> wrote in message
news:e54msp$24k$1_at_sea.gmane.org...
Maarten Kronenburg escreveu:

> Thanks for your comments.
> The integer is not a drop-in replacement for any base type;
> because it accesses its data through a pointer, and has to
> check on certain conditions and carries etc, it is much slower
> than the base types.

He meant by "drop-in replacement" that an integer object should behave
exactly like an int object, so that we could just replace

  int i;

by

  integer i;

and everything just work like magic.
That would be highly desirable.

> A conversion operator will generate ambiguities in
> expressions, even a bool conversion operator,
> because bool can be implicitly converted to int.

That can be avoided with the trick mentioned by the parent:

> First, an operator unspecified_bool_type(), like the one found in
> shared_ptr.

The trick involves a pointer-to-member; those are not implicitly
convertible to int, but are "testable for nullness".

The unique_ptr proposal also uses this trick.

--
 Pedro Lamarão
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost

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