Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-11-22 17:15:10

In message <00cd01c054c6$62b4d590$37781990_at_[hidden]>, Greg Colvin
<gcolvin_at_[hidden]> writes
>I'm certainly amenable to these improvements to shared_ptr, but are they
>truly necessary? It seems that for a pointer or a shared_ptr to a
>function or to a functor that (*f)() is a legitimate way to make a call.

In reflecting the look and feel of a pointer in a smart pointer there
are a number of decisions that need to be taken. A number of them relate
to the dereferencing operators available, and in the case of pointers,
depending on their type, this comes down to *, ->, [], () and ->*.
Assuming a templated smart pointer, all except [] can be constrained wrt
usage, ie if a target does not support () expressions that use it will
simply not compile (ditto for ->, etc).

Although (*f)() is a legitimate way to make a call, this is defined to
be equivalent to f() (not vice-versa), which we cannot currently write.
Even more compelling than consistency with the built-ins is the fact
that generic algorithms expect to write f() and not (*f)().

I think all that suggests that it is truly necessary (for some
appropriate definition of 'truly' :->), and I for one would certainly
welcome its addition to current and future smart pointers.


  Kevlin Henney phone: +44 117 942 2990
  Curbralan Limited mobile: +44 7801 073 508
  mailto:kevlin_at_[hidden] fax: +44 870 052 2289

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