Hi there, I have posted this question last Friday, already. But maybe
my example was too confusing. Here is a more simple example.
Basically, I don't see what the big difference is when using
boost::bind with a pointer vector ( std::vector ) and a static
array of info.
Please consider the following code:
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include
using namespace std;
using namespace boost;
struct info
{
int a;
string s;
};
static info table[] =
{
{ 16, "Hello" },
{ 18, "Moin" }
};
string& get_s( info* p )
{
return p->s;
}
int _tmain(int argc, _TCHAR* argv[])
{
{
vector v;
find_if( v.begin(), v.end()
, bind( equal_to<string>()
, bind( &get_s, _1 )
, "Moin" ));
}
{
find_if( &table[0], &table[0] + 2
, bind( equal_to<string>()
, bind( &get_s, _1 )
, "Moin" ));
}
}
The second find_if wont complie using MSVC 7.1. The errors are:
c:\boost\boost\bind.hpp(219) : error C2664: 'std::string &(info *)' :
cannot convert parameter 1 from 'info' to 'info *'
No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called
c:\boost\boost\bind\bind_template.hpp(139) : see reference to
function template instantiation 'R boost::_bi::list1<A1>::operator
()::result_type,std::string&(__cdecl *)(info
*),A>(boost::_bi::type<T>,F & ,A &,long)' being compiled
with
[
R=boost::_bi::bind_t>::B1>>::result_type,
A1=boost::_bi::list_av_1>::B1,
F=std::string &(__cdecl *)(info *),
L=boost::_bi::list1>::B1>,
A=const boost::_bi::list1,
T=boost::_bi::bind_t>::B1>>::result_type
]
c:\boost\boost\bind.hpp(213) : see reference to function
template instantiation 'boost::_bi::bind_t::result_type
boost::_bi::bind_t::eval(A &)'
being compiled
with
[
R=std::string &,
F=std::string &(__cdecl *)(info *),
L=boost::_bi::list1>::B1>,
A1=info &,
A=const boost::_bi::list1
]
[snip]
Any ideas?
Christian