|
Boost Users : |
From: Christian Henning (chhenning_at_[hidden])
Date: 2007-03-23 12:14:38
Hi there, for whatever reason the following code doesn't compile:
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <boost/any.hpp>
#include <boost/bind.hpp>
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
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