|
Boost : |
Subject: Re: [boost] [type_erasure] issue when taking any<> by const ref
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-11-12 19:45:13
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk