Boost logo

Boost :

From: Pedro Lamarão (pedro.lamarao_at_[hidden])
Date: 2006-05-25 12:44:08

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;


  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

Boost list run by bdawes at, gregod at, cpdaniel at, john at