Boost logo

Boost Users :

Subject: [Boost-users] boost::bind issues
From: Littlefield, Tyler (tyler_at_[hidden])
Date: 2012-10-09 01:44:04


Hello all:
I'm trying to boost::bind a couple of callbacks and was getting errors;
could someone help me figure out what's going on?
First, the errors:
19:22:36: Compiling staticObject.cpp.
staticObject.cpp: In constructor ‘StaticObject::StaticObject()’:
staticObject.cpp:20:143: error: no matching function for call to
‘OlcStringEntry::OlcStringEntry(std::string, int,
boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, BaseObject>,
boost::_bi::list1<boost::_bi::value<StaticObject*> > >,
boost::_bi::bind_t<void, boost::_mfi::mf1<void, BaseObject, const
std::basic_string<char>&>,
boost::_bi::list2<boost::_bi::value<StaticObject*>, boost::arg<1> > >)’
staticObject.cpp:20:143: note: candidates are:
In file included from staticObject.h:7:0,
from staticObject.cpp:5:
olc.h:48:3: note: OlcStringEntry::OlcStringEntry(const string&, FLAG,
StringGetter&, StringSetter&)
olc.h:48:3: note: no known conversion for argument 3 from
‘boost::_bi::bind_t<std::basic_string<char>,
boost::_mfi::cmf0<std::basic_string<char>, BaseObject>,
boost::_bi::list1<boost::_bi::value<StaticObject*> > >’ to
‘StringGetter& {aka boost::function<std::basic_string<char>()>&}’
olc.h:42:7: note: OlcStringEntry::OlcStringEntry(const OlcStringEntry&)
olc.h:42:7: note: candidate expects 1 argument, 4 provided
now, here's how I call it:
AddOlc(new OlcStringEntry(std::string("name"), OF_NORMAL,
boost::bind(&BaseObject::GetName, this),
boost::bind(&BaseObject::SetName, this, _1)));
baseobject's relevant methods look like:
virtual std::string GetName() const;
virtual void SetName(const std::string &s);
and the relevant tidbits from olc.h:
typedef boost::function<std::string()> StringGetter;
typedef boost::function<void (const std::string&)> StringSetter;
and OlcStringEntry's ctor looks like:
OlcStringEntry(const std::string &name, FLAG flag, StringGetter& get,
StringSetter& set);
Any info here would be appreciated.
Thanks,

-- 
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.

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