when trying to compile the following code (cut from the
boost.function test suite):
#include
#include
#include <iostream>
#include <string>
#include <functional>
struct X
{
X(int v) : value(v) {}
int twice() const { return 2*value; }
int plus(int v) { return value + v; }
int value;
};
int main()
{
using namespace boost;
boost::function f1(&X::twice);
X one(1);
cout << "f1(one) = " << f1(&one) << endl;
return 0;
}
_____________________________________________
i get the following errors:
/usr/local/include/boost/function/function_template.hpp: In function
`static int boost::detail::function::function_obj_invoker1::invoke(boost::detail::function::any_pointer, X *)':
/usr/local/include/boost/function/function_template.hpp:689:
instantiated from `boost::function1::assign_to(int (X::* &)()
const, boost::detail::function::function_obj_tag)'
/usr/local/include/boost/function/function_template.hpp:618:
instantiated from `boost::function1::assign_to(int (X::* &)()
const)'
/usr/local/include/boost/function/function_template.hpp:463:
instantiated from `boost::function1::function1(int (X::* &)()
const)'
/usr/local/include/boost/function.hpp:459: instantiated from
`boost::function::function(int (X::*
&)() const)'
hello.C:21: instantiated from here
/usr/local/include/boost/function/function_template.hpp:272: pointer
to member function called, but not in class scope
/usr/local/include/boost/function/function_template.hpp:272: warning:
control reaches end of non-void function
`boost::detail::function::function_obj_invoker1::invoke(boost::detail::function::any_pointer, X *)'
/usr/local/include/g++-3/stl_alloc.h: At top level:
/usr/local/include/g++-3/stl_alloc.h: In instantiation of
`allocator':
/usr/local/include/boost/function/function_base.hpp:131:
instantiated from `boost::detail::function::functor_managerboost::function_base >'
/usr/local/include/boost/function/function_template.hpp:691:
instantiated from `boost::function1::assign_to(int (X::* &)()
const, boost::detail::function::function_obj_tag)'
/usr/local/include/boost/function/function_template.hpp:618:
instantiated from `boost::function1::assign_to(int (X::* &)()
const)'
/usr/local/include/boost/function/function_template.hpp:463:
instantiated from `boost::function1::function1(int (X::* &)()
const)'
/usr/local/include/boost/function.hpp:459: instantiated from
`boost::function::function(int (X::*
&)() const)'
hello.C:21: instantiated from here
/usr/local/include/g++-3/stl_alloc.h:750: `allocator::address(int (X::* &)() const) const' has already been
declared in `allocator'
make: *** [hello.o] Error 1
___________________________________
this code should compile (its just copied from the test code) and my
compiler setup should work according to the boost compiler status
page.
Any ideas what i'm doing wrong?
-Darin Buck