Subject: Re: [boost] Formal Review Request: TypeErasure
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2012-05-27 05:13:13
On 26/05/12 21:25, Jeremy Maitin-Shepard wrote:
> Steven Watanabe <watanabesj <at> gmail.com> writes:
>> 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
> 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).
In the past I've achieved this by defining both const and non-const
member functions and forwarding to a free function which then can be
templated on the type of this. As you say, things get worse with member
reference qualification because now three member functions are needed.
I don't know whether such a technique would be applicable in this case.