Boost logo

Boost Users :

From: Darin Buck (darinbuck_at_[hidden])
Date: 2001-11-28 21:25:39


when trying to compile the following code (cut from the
boost.function test suite):

#include <boost/bind.hpp>
#include <boost/function.hpp>
#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<int, X*> 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<int (X::*)
() const,int,X *>::invoke(boost::detail::function::any_pointer, X *)':
/usr/local/include/boost/function/function_template.hpp:689:
instantiated from `boost::function1<int,X
*,boost::empty_function_policy,boost::empty_function_mixin,allocator<b
oost::function_base> >::assign_to<int (X::*)() const>(int (X::* &)()
const, boost::detail::function::function_obj_tag)'
/usr/local/include/boost/function/function_template.hpp:618:
instantiated from `boost::function1<int,X
*,boost::empty_function_policy,boost::empty_function_mixin,allocator<b
oost::function_base> >::assign_to<int (X::*)() const>(int (X::* &)()
const)'
/usr/local/include/boost/function/function_template.hpp:463:
instantiated from `boost::function1<int,X
*,boost::empty_function_policy,boost::empty_function_mixin,allocator<b
oost::function_base> >::function1<int (X::*)() const>(int (X::* &)()
const)'
/usr/local/include/boost/function.hpp:459: instantiated from
`boost::function<int,X
*,boost::detail::function::unusable,boost::detail::function::unusable,
boost::detail::function::unusable,boost::detail::function::unusable,bo
ost::detail::function::unusable,boost::detail::function::unusable,boos
t::detail::function::unusable,boost::detail::function::unusable,boost:
:detail::function::unusable>::function<int (X::*)() const>(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<int (X::*)()
const,int,X *>::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<int (X::*)() const>':
/usr/local/include/boost/function/function_base.hpp:131:
instantiated from `boost::detail::function::functor_manager<int (X::*)
() const,allocator<boost::function_base> >'
/usr/local/include/boost/function/function_template.hpp:691:
instantiated from `boost::function1<int,X
*,boost::empty_function_policy,boost::empty_function_mixin,allocator<b
oost::function_base> >::assign_to<int (X::*)() const>(int (X::* &)()
const, boost::detail::function::function_obj_tag)'
/usr/local/include/boost/function/function_template.hpp:618:
instantiated from `boost::function1<int,X
*,boost::empty_function_policy,boost::empty_function_mixin,allocator<b
oost::function_base> >::assign_to<int (X::*)() const>(int (X::* &)()
const)'
/usr/local/include/boost/function/function_template.hpp:463:
instantiated from `boost::function1<int,X
*,boost::empty_function_policy,boost::empty_function_mixin,allocator<b
oost::function_base> >::function1<int (X::*)() const>(int (X::* &)()
const)'
/usr/local/include/boost/function.hpp:459: instantiated from
`boost::function<int,X
*,boost::detail::function::unusable,boost::detail::function::unusable,
boost::detail::function::unusable,boost::detail::function::unusable,bo
ost::detail::function::unusable,boost::detail::function::unusable,boos
t::detail::function::unusable,boost::detail::function::unusable,boost:
:detail::function::unusable>::function<int (X::*)() const>(int (X::*
&)() const)'
hello.C:21: instantiated from here
/usr/local/include/g++-3/stl_alloc.h:750: `allocator<int (X::*)()
const>::address(int (X::* &)() const) const' has already been
declared in `allocator<int (X::*)() const>'
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


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