Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-05-31 15:24:51


Alain Cormier wrote:

[...]

> int fct_param_const(const int value) const
> { return m_value + value; }

[...]

> Is this a correct behavior from boost::bind? Does the only solution
> is to remove the const from our function? We have so much difficulty
> to stay const-correct, I do not want to send a signal to our team
> that const isn't good (but maybe too much const isn't good :D).
> Anyway, what do you suggest?
>
> By the way. I am using VC6 (SP5) under Win2000 and boost 1.33.1.

This is a bug in VC6, see

http://boost.org/libs/bind/bind.html#err_const_arg

Top-level const in a function argument list is a peculiar thing. It is
ignored for the purposes of the function signature, so

void f( int const );

and

void f( int );

actually declare the same function, and there is no such thing as void
(*)( int const ), the correct type is void (*) ( int ).

Such a const qualifier is only relevant on a function definition and makes
the actual argument const. It has no impact on the const correctness of the
caller side since a by-value parameter cannot affect the argument.

boost::bind can do nothing about the fact that VC6 is confused by such
functions, except maybe to encourage you to upgrade. :-)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net