Hi there, for whatever reason the following code doesn't compile:
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include
#include
using namespace std;
using namespace boost;
struct A {};
struct B {};
struct field
{
const any a;
const string s;
};
static field table[] =
{
{ any( A() ), "Hello" },
{ any( B() ), "Moin" }
};
template<class T>
const T& get( field* p )
{
return p->s;
}
int _tmain(int argc, _TCHAR* argv[])
{
string s( "Hello" );
size_t size = sizeof(table) / sizeof(field);
field* p = find_if( &table[0], &table[0] + size, boost::bind(
equal_to<string>()
, bind( get<string>, _1 )
, s ));
}
The problem is that bind doesn't like it when _1 is a pointer. I
believe. So, what is wrong? On some other threads I could see that
slightly different example worked.
Thanks ahead,
Christian