Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-08-19 09:42:16

Beman Dawes wrote:
> At 07:45 PM 8/12/99 +0200, Valentin Bonnard wrote:

> >Hum... the ``right'' way to write implicit_cast is:
> >
> >template <typename To>
> >inline
> >To implicit_cast (To x)
> >{ return x; }
> >
> >Otherwise the implicit cast is down in the scope and
> >with the priviledges of implicit_cast.
> I'm don't understand what you mean by "priviledges".

First, I meant privilege.

The Webster says

:a right or immunity granted as a peculiar benefit, advantage, or favor:
     PREROGATIVE; esp: such a right or immunity attached specif.
     to a position or an office

This word is actually used in the standard, in
access privileges. It's the rights wrt to access

> >In other words, implicit_cast should have macro
> >behaviour, not proper function behaviour.
> Could you give an example where it matters?

When a the caller of implicit_cast, say foo(),
has some privilege (right for the purpose of
access control) that implicit_cast doesn't
have (since implicit_cast a priori isn't a
friend of anyone). For example foo might be
a friend of some class, which is a privilege.
The privilege might be needed to do the cast.

With the proposed change, implicit_cast is the
identity function and the cast is still done
implicitly in the caller, with the correct
access control (with the rights of the caller).

The same should apply to polymorphic_cast, except
that I don't know how to give polymorphic_cast
macro behaviour (well, actually it's impossible
to give polymorphic_cast macro behaviour).

Valentin Bonnard

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