Hello all: I'm having some issues with boost::bind. I'm using it as normal, but I'm still getting a ton of errors: In file included from staticObject.h:7:0, from staticObject.cpp:6: olc.h: In instantiation of ‘class OlcEntry<boost::function<std::basic_string<char>()__attribute__((const))>, boost::function<void(const std::basic_string<char>&)> >’: staticObject.cpp:160:60: required from here olc.h:43:5: error: ‘OlcEntry<G, S>::_getter’ has incomplete type here's what the specific lines on staticObject.cpp looks like: sgroup->AddEntry(new OlcStringEntry("name", "Sets the name of the object", OF_NORMAL, boost::bind(&StaticObject::GetName, _1), boost::bind(&StaticObject::SetName, _1, _2))); and here's the incomplete type deal. typedef boost::function<std::string () const> StringGetter; typedef boost::function<void (const std::string&)> StringSetter; template <class G, class S> class OlcEntry:public IOlcEntry { protected: G _getter; S _setter; public: OlcEntry(const std::string &name, const std::string &help, FLAG flag, const G& getter, const S& setter) :IOlcEntry(name, help, flag) { _setter = setter; _getter = getter; } ... }; Any ideas/help would be awesome. 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.
On Sun, Apr 21, 2013 at 11:22 AM, Littlefield, Tyler <tyler@tysdomain.com>wrote:
Hello all: I'm having some issues with boost::bind. I'm using it as normal, but I'm still getting a ton of errors: In file included from staticObject.h:7:0, from staticObject.cpp:6: olc.h: In instantiation of ‘class OlcEntry<boost::function<std::** basic_string<char>()__**attribute__((const))>, boost::function<void(const std::basic_string<char>&)> >’: staticObject.cpp:160:60: required from here olc.h:43:5: error: ‘OlcEntry<G, S>::_getter’ has incomplete type here's what the specific lines on staticObject.cpp looks like: sgroup->AddEntry(new OlcStringEntry("name", "Sets the name of the object", OF_NORMAL, boost::bind(&StaticObject::**GetName, _1), boost::bind(&StaticObject::**SetName, _1, _2))); and here's the incomplete type deal. typedef boost::function<std::string () const> StringGetter; typedef boost::function<void (const std::string&)> StringSetter; template <class G, class S> class OlcEntry:public IOlcEntry { protected: G _getter; S _setter; public: OlcEntry(const std::string &name, const std::string &help, FLAG flag, const G& getter, const S& setter) :IOlcEntry(name, help, flag) { _setter = setter; _getter = getter; } ... };
Any ideas/help would be awesome. Thanks,
1) It's difficult to read your message when everything is single-spaced. 2) I think you'd get more help if you had a small, self-contained example exhibiting your problem. - Jeff
2013/4/21 Littlefield, Tyler <tyler@tysdomain.com>:
Hello all: I'm having some issues with boost::bind. I'm using it as normal, but I'm still getting a ton of errors: In file included from staticObject.h:7:0, from staticObject.cpp:6: olc.h: In instantiation of ‘class OlcEntry<boost::function<std::basic_string<char>()__attribute__((const))>, boost::function<void(const std::basic_string<char>&)> >’: staticObject.cpp:160:60: required from here olc.h:43:5: error: ‘OlcEntry<G, S>::_getter’ has incomplete type here's what the specific lines on staticObject.cpp looks like: sgroup->AddEntry(new OlcStringEntry("name", "Sets the name of the object", OF_NORMAL, boost::bind(&StaticObject::GetName, _1), boost::bind(&StaticObject::SetName, _1, _2))); and here's the incomplete type deal. typedef boost::function<std::string () const> StringGetter; typedef boost::function<void (const std::string&)> StringSetter; template <class G, class S> class OlcEntry:public IOlcEntry { protected: G _getter; S _setter; public: OlcEntry(const std::string &name, const std::string &help, FLAG flag, const G& getter, const S& setter) :IOlcEntry(name, help, flag) { _setter = setter; _getter = getter; } ... };
Any ideas/help would be awesome. Thanks,
StringSetter type accept 1 argument, however boost::bind(&StaticObject::Set Name, _1, _2) produces a functor that accepts two arguments. Same thing with StringGetter. You need to provide correct pointer to bind instead of _1 so that your example could work: sgroup->AddEntry(new OlcStringEntry("name", "Sets the name of the object", OF_NORMAL); sgroup->Last()->_setter = boost::bind(&StaticObject::SetName, sgroup->Last(), _1); sgroup->Last()->_getter = boost::bind(&StaticObject::GetName, sgroup->Last()); -- Best regards, Antony Polukhin
participants (3)
-
Antony Polukhin
-
Jeffrey Lee Hellrung, Jr.
-
Littlefield, Tyler