Boost logo

Boost Users :

Subject: Re: [Boost-users] a quick question regarding boost::bind with a test case
From: Littlefield, Tyler (tyler_at_[hidden])
Date: 2011-04-11 14:19:54


Hello:
Here is what I'm going for; maybe this will explain
I have the following code in my project:
AddOlc("name", "Please enter the name of the object", STRING,
boost::bind(OlcString, _1, _2, _3, boost::bind(&Entity::GetName, this),
boost::bind(&Entity::SetName, this, _1)));
OlcString:
void OlcString(Entity* ed, Player* mob, const Variant* input,
boost::function<std::string ()> get, boost::function<void (const
std::string&)> set)
{
if (input->Typeof() != VAR_STR)
{
mob->Message(MSG_ERROR, "Invalid input.");
return;
}

set(input->GetStr());
}
The point is for the callback (OlcString) to use the setter to set the
name of the object, which is not what is happening.
Here are the compile erorrs:
12:19:26: Compiling entity.cpp.
In file included from /usr/local/include/boost/bind.hpp:22:0,
from entity.cpp:5:
/usr/local/include/boost/bind/bind.hpp: In member function ‘void
boost::_bi::list5<A1, A2, A3, A4,
A5>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = void
(*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), A = boost::_bi::list3<Entity*&, Player*&,
const Variant*&>, A1 = boost::arg<1>, A2 = boost::arg<2>, A3 =
boost::arg<3>, A4 = boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >, A5 =
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > >]’:
/usr/local/include/boost/bind/bind_template.hpp:116:59: instantiated
from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F,
L>::operator()(A1&, A2&, A3&) [with A1 = Entity*, A2 = Player*, A3 =
const Variant*, R = void, F = void (*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), L = boost::_bi::list5<boost::arg<1>,
boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > >, boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/local/include/boost/function/function_template.hpp:153:11:
instantiated from ‘static void
boost::detail::function::void_function_obj_invoker3<FunctionObj, R, T0,
T1, T2>::invoke(boost::detail::function::function_buffer&, T0, T1, T2)
[with FunctionObj = boost::_bi::bind_t<void, void (*)(Entity*, Player*,
const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*]’
/usr/local/include/boost/function/function_template.hpp:907:60:
instantiated from ‘void boost::function3<R, T1, T2,
T3>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void, void
(*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), boost::_bi::list5<boost::arg<1>,
boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*]’
/usr/local/include/boost/function/function_template.hpp:722:7:
instantiated from ‘boost::function3<R, T1, T2, T3>::function3(Functor,
typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = boost::_bi::bind_t<void, void (*)(Entity*,
Player*, const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type = int]’
/usr/local/include/boost/function/function_template.hpp:1042:16:
instantiated from ‘boost::function<R(T0, T1, T2)>::function(Functor,
typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = boost::_bi::bind_t<void, void (*)(Entity*,
Player*, const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type = int]’
entity.cpp:27:177: instantiated from here
/usr/local/include/boost/bind/bind.hpp:525:9: error: conversion from
‘boost::_bi::result_traits<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char, std::char_traits<char>, std::allocator<char> >&>
>::type’ to non-scalar type ‘boost::function<void(const
std::basic_string<char>&)>’ requested
/usr/local/include/boost/bind/bind.hpp: In member function ‘void
boost::_bi::list2<A1, A2>::operator()(boost::_bi::type<void>, F&, A&,
int) [with F = boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, A = const boost::_bi::list3<Entity*&,
Player*&, const Variant*&>, A1 = boost::_bi::value<Entity*>, A2 =
boost::arg<1>]’:
/usr/local/include/boost/bind/bind_template.hpp:318:59: instantiated
from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F,
L>::eval(A&) [with A = const boost::_bi::list3<Entity*&, Player*&, const
Variant*&>, R = void, F = boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, L =
boost::_bi::list2<boost::_bi::value<Entity*>, boost::arg<1> >,
boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/local/include/boost/bind/bind.hpp:376:136: instantiated from
‘typename boost::_bi::result_traits<R, F>::type boost::_bi::list3<A1,
A2, A3>::operator[](boost::_bi::bind_t<R, F, L>&) const [with R = void,
F = boost::_mfi::mf1<void, Entity, const std::basic_string<char>&>, L =
boost::_bi::list2<boost::_bi::value<Entity*>, boost::arg<1> >, A1 =
Entity*&, A2 = Player*&, A3 = const Variant*&, typename
boost::_bi::result_traits<R, F>::type = void]’
/usr/local/include/boost/bind/bind.hpp:525:9: instantiated from ‘void
boost::_bi::list5<A1, A2, A3, A4,
A5>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = void
(*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), A = boost::_bi::list3<Entity*&, Player*&,
const Variant*&>, A1 = boost::arg<1>, A2 = boost::arg<2>, A3 =
boost::arg<3>, A4 = boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >, A5 =
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > >]’
/usr/local/include/boost/bind/bind_template.hpp:116:59: instantiated
from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F,
L>::operator()(A1&, A2&, A3&) [with A1 = Entity*, A2 = Player*, A3 =
const Variant*, R = void, F = void (*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), L = boost::_bi::list5<boost::arg<1>,
boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > >, boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/local/include/boost/function/function_template.hpp:153:11:
instantiated from ‘static void
boost::detail::function::void_function_obj_invoker3<FunctionObj, R, T0,
T1, T2>::invoke(boost::detail::function::function_buffer&, T0, T1, T2)
[with FunctionObj = boost::_bi::bind_t<void, void (*)(Entity*, Player*,
const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*]’
/usr/local/include/boost/function/function_template.hpp:907:60:
instantiated from ‘void boost::function3<R, T1, T2,
T3>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void, void
(*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), boost::_bi::list5<boost::arg<1>,
boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*]’
/usr/local/include/boost/function/function_template.hpp:722:7:
instantiated from ‘boost::function3<R, T1, T2, T3>::function3(Functor,
typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = boost::_bi::bind_t<void, void (*)(Entity*,
Player*, const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type = int]’
/usr/local/include/boost/function/function_template.hpp:1042:16:
instantiated from ‘boost::function<R(T0, T1, T2)>::function(Functor,
typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = boost::_bi::bind_t<void, void (*)(Entity*,
Player*, const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type = int]’
entity.cpp:27:177: instantiated from here
/usr/local/include/boost/bind/bind.hpp:313:9: error: no match for call
to ‘(boost::_mfi::mf1<void, Entity, const std::basic_string<char>&>)
(Entity*&, Entity*&)’
/usr/local/include/boost/bind/mem_fn_template.hpp:163:7: note:
candidates are: R boost::_mfi::mf1<R, T, A1>::operator()(T*, A1) const
[with R = void, T = Entity, A1 = const std::basic_string<char>&]
/usr/local/include/boost/bind/mem_fn_template.hpp:184:7: note: R
boost::_mfi::mf1<R, T, A1>::operator()(T&, A1) const [with R = void, T =
Entity, A1 = const std::basic_string<char>&]
In file included from
/usr/local/include/boost/function/detail/maybe_include.hpp:13:0,
from /usr/local/include/boost/function/detail/function_iterate.hpp:14,
from
/usr/local/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:47,
from /usr/local/include/boost/function.hpp:64,
from mud.h:4,
from entity.h:10,
from entity.cpp:6:
/usr/local/include/boost/function/function_template.hpp: In static
member function ‘static R
boost::detail::function::function_obj_invoker0<FunctionObj,
R>::invoke(boost::detail::function::function_buffer&) [with FunctionObj
= std::basic_string<char>, R = std::basic_string<char>]’:
/usr/local/include/boost/function/function_template.hpp:907:60:
instantiated from ‘void boost::function0<R>::assign_to(Functor) [with
Functor = std::basic_string<char>, R = std::basic_string<char>]’
/usr/local/include/boost/function/function_template.hpp:722:7:
instantiated from ‘boost::function0<R>::function0(Functor, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = std::basic_string<char>, R =
std::basic_string<char>, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type = int]’
/usr/local/include/boost/function/function_template.hpp:1042:16:
instantiated from ‘boost::function<R()>::function(Functor, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = std::basic_string<char>, R =
std::basic_string<char>, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type = int]’
/usr/local/include/boost/bind/bind.hpp:525:9: instantiated from ‘void
boost::_bi::list5<A1, A2, A3, A4,
A5>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = void
(*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), A = boost::_bi::list3<Entity*&, Player*&,
const Variant*&>, A1 = boost::arg<1>, A2 = boost::arg<2>, A3 =
boost::arg<3>, A4 = boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >, A5 =
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > >]’
/usr/local/include/boost/bind/bind_template.hpp:116:59: instantiated
from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F,
L>::operator()(A1&, A2&, A3&) [with A1 = Entity*, A2 = Player*, A3 =
const Variant*, R = void, F = void (*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), L = boost::_bi::list5<boost::arg<1>,
boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > >, boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/local/include/boost/function/function_template.hpp:153:11:
instantiated from ‘static void
boost::detail::function::void_function_obj_invoker3<FunctionObj, R, T0,
T1, T2>::invoke(boost::detail::function::function_buffer&, T0, T1, T2)
[with FunctionObj = boost::_bi::bind_t<void, void (*)(Entity*, Player*,
const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*]’
/usr/local/include/boost/function/function_template.hpp:907:60:
instantiated from ‘void boost::function3<R, T1, T2,
T3>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void, void
(*)(Entity*, Player*, const Variant*,
boost::function<std::basic_string<char>()>, boost::function<void(const
std::basic_string<char>&)>), boost::_bi::list5<boost::arg<1>,
boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*]’
/usr/local/include/boost/function/function_template.hpp:722:7:
instantiated from ‘boost::function3<R, T1, T2, T3>::function3(Functor,
typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = boost::_bi::bind_t<void, void (*)(Entity*,
Player*, const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type = int]’
/usr/local/include/boost/function/function_template.hpp:1042:16:
instantiated from ‘boost::function<R(T0, T1, T2)>::function(Functor,
typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = boost::_bi::bind_t<void, void (*)(Entity*,
Player*, const Variant*, boost::function<std::basic_string<char>()>,
boost::function<void(const std::basic_string<char>&)>),
boost::_bi::list5<boost::arg<1>, boost::arg<2>, boost::arg<3>,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, Entity>,
boost::_bi::list1<boost::_bi::value<Entity*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, Entity, const
std::basic_string<char>&>, boost::_bi::list2<boost::_bi::value<Entity*>,
boost::arg<1> > > > >, R = void, T0 = Entity*, T1 = Player*, T2 = const
Variant*, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type = int]’
entity.cpp:27:177: instantiated from here
/usr/local/include/boost/function/function_template.hpp:132:42: error:
no match for call to ‘(std::basic_string<char>) ()’
make: *** [entity.o] Error 1

Thanks in advance,
Ty
On 4/11/2011 12:12 PM, Steven Watanabe wrote:
> AMDG
>
> On 04/11/2011 10:44 AM, Littlefield, Tyler wrote:
>> I have a quick question regarding boost::bind, as the subject line says.
>>
>> This isn't a very viable example, but it works well enough to show what
>> I want.
>> I have a callback I am using boost::bind to bind to, and I am passing a
>> function object in as shown by the following code:
>> #include <cstdio>
>> #include <boost/bind.hpp>
>> #include <boost/function.hpp>
>>
>> class Math
>> {
>> public:
>> void Add(int a, int b, int c, boost::function<void (int)> printer);
>> {
>> printer(a+b+c);
>> }
>> };
>>
>> void Printer(int p)
>> {
>> printf("%d\n", p);
>> }How might I make this work? I am not sure how I can pass that as the
>> fourth argument so that the function can be called like (1,2,3) etc.
>> Also, in the actual problem I moved the function object to the first
>> argument, (which just ment changing the prototype and actual function),
>> but I still got errors.
>>
>
> I'm not sure exactly what you're trying to do,
> but the following should work:
> boost::bind(&Math::Add, Math(), _1, _2, _3, &Printer)(1, 2, 3)
>
> In Christ,
> Steven Watanabe
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Thanks,
Ty

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