Boost logo

Boost :

Subject: Re: [boost] [type_erasure] issue when taking any<> by const ref
From: Thomas Petit (thomas.petit33_at_[hidden])
Date: 2012-11-13 18:03:55


> Fixed.
Nice !

> You need to use has_member<void(), const _self> for
> const member functions.

Ok, I understand now. I didn't realize that has_member<void()> was actually
a shortcut to has_member<void(), _self>.
Thanks.

2012/11/13 Steven Watanabe <watanabesj_at_[hidden]>

> AMDG
>
> On 11/12/2012 03:33 PM, Thomas Petit wrote:
> > I'm playing with the boost type erasure library (from the sandbox) and
> hit
> > some issues.
> >
> > <snip>
> > In the previous code, if add a const here :
> >
> > for(const any_free_t& af : v)
> > {
> > free(af);
> > }
> >
> > then instead of calling the int overload of the free function and the
> > template overload with a double type,
> > the templated free function is called both time but, unfortunately the
> type
> > of T is always the same as the any.
> >
>
> Fixed.
>
> > Another point, if I add a const here :
> > for(const any_member_t& am : v2)
> > {
> > am .member();
> > }
> > then I get a compile error. (with visual 2012 and gcc 4.7)
> >
>
> You need to use has_member<void(), const _self> for
> const member functions.
>
> > I'm a bit puzzled by this behavior. Are any<> types never supposed to be
> > taken by const ref ?
> > How can we iterate over anys while preserving constness ?
> >
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk