|
Boost Users : |
From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-01-04 13:27:03
Bind has been working very well for some of the things I have been
wanting to do. I have run into a rather puzzling problem this time and
was wondering what was happening:
Here is the example:
void f( int )
{
}
struct array_obj
{
int operator[]( int ){ return NULL; }
};
int main()
{
array_obj a;
int array[1];
int value = a[0];
boost::bind( f, _1 )( 3 );
boost::bind( f, _1 )( value );
boost::bind( f, _1 )( array[0] );
boost::bind( f, _1 )( a[0] );
return 0;
}
The first three bind statements compile just fine. The third one issues
an error:
function call 'operator()(int)' does not match.
Along with all 20 variations of operator() generated by bind.
Obviously there is something amiss with going through the return value of
operator[](). I also get the same problem using an iterator which would
be going through operator*().
I am using CodeWarrior 7 on Mac on OS X. Could this be a compiler
specific problem?
I can work around the problem using bind1st but it seems odd that bind1st
works and bind doesnt? Could CW have included some magic in bind1st to
work around this?
Thanks for the help,
..Duane
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