Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-07-30 09:31:39


Michael Nicolella wrote:
> Having trouble compiling this code. Only tested in VC8:
>
> Removing 'const' from only the static class function seems to allow
> it to compile. Below is the error messages...
>
>
>
> #include <boost/bind.hpp>
> #include <boost/function.hpp>
>
> struct A
> {
> static void foo( const int )
> {
> }
> };
>
> void bar( const int )
> {
> }
>
> int main()
> {
> boost::bind( &A::foo, _1 ) ;
> boost::bind( &bar, _1 ) ;
> }

This is a compiler bug. My advice is to avoid top-level const in signatures.
You can still use it in the definition if you insist (although I've never
seen its utility):

struct A
{
   static void foo( int );
};

int main()
{
   boost::bind( &A::foo, _1 ) ;
}

void A::foo( const int )
{
}


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