Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: TypeErasure
From: Jeremy Maitin-Shepard (jeremy_at_[hidden])
Date: 2012-05-26 16:25:28

Steven Watanabe <watanabesj <at>> writes:
> On 05/24/2012 04:21 PM, Jeremy Maitin-Shepard wrote:
> > Steven Watanabe <watanabesj <at>> writes:

> The situation is one that isn't even
> allowed with C++ references:
> int & const ref = i; // error

True, but a reference can be a member of a struct to which you have a const
reference, in which case it is treated just like a pointer, i.e. no const

> The problem with
> const any<Concept, _self&> xx;
> is that anything that isn't specially
> designed to handle it will see the
> const and treat it as const. Some
> parts of the library will work with
> it, but in others it was just too
> difficult.

I can see now that there would be a problem with using concept_interface to
inject member functions, since there is no way to simultaneously define both a
const and non-const member function. Particularly with the introduction of
member reference qualification, not being able to template on the type of
"this" is a significant defect in the language. At least it can be worked
around by not using member functions (except for operator overloading where it
can't be avoided).

Maybe support for _self* or even shared_ptr<_self> (as a special syntax to
indicate that internally a shared_ptr to the underlying type should be stored)
could be a useful alternative?

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