Boost logo

Boost Users :

From: Victor A. Wagner Jr. (vawjr_at_[hidden])
Date: 2006-07-30 12:33:23


At 07:31 2006-07-30, Peter Dimov wrote:
>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):

It tells the compiler that your code won't change the variable. and
the compiler obligingly gives you an error if you accidently try.
One presumes that it could also enable some optimizations if the
compiler _knows_ the value can't be changed.

>struct A
>{
> static void foo( int );
>};
>
>int main()
>{
> boost::bind( &A::foo, _1 ) ;
>}
>
>void A::foo( const int )
>{
>}
>
>_______________________________________________
>Boost-users mailing list
>Boost-users_at_[hidden]
>http://lists.boost.org/mailman/listinfo.cgi/boost-users

Victor A. Wagner Jr. http://rudbek.com
The five most dangerous words in the English language:
               "There oughta be a law"


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