boost-bind

C++:BOOST-bind error: no matching function for call to 'bind(<unresolved overloaded function type>, …?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 15:37:43
问题 I tried to turn this boost-asio server into a class and I got this one error trying to compile it, C:\Documents and Settings\tcpip_server\TCPIP_server.h||In member function 'void TCPIP_server::server(boost::asio::io_service&, short int)':| C:\Documents and Settings\tcpip_server\TCPIP_server.h|56|error: no matching function for call to 'bind(<unresolved overloaded function type>, boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost:

Passing a unique_ptr reference to boost::bind?

泪湿孤枕 提交于 2019-12-13 13:19:23
问题 I'm on CentOS 6.6 (gcc 4.4.7) and developing with Boost.Asio (1.41). I'd like io_service to call member function run() in manger object m when it starts. The code I'm trying to compile looks like: #include <memory> #include <boost/asio.hpp> #include <boost/bind.hpp> boost::asio::io_service io; std::unique_ptr<manager> m; m = std::make_unique<manager>; io.post(boost::bind(&manager::run, &m)); gcc pitches a fit on the boost::bind statement, which includes: /usr/include/boost/bind/mem_fn

Using boost::bind on std::string::find fails to compile

纵饮孤独 提交于 2019-12-12 17:13:09
问题 I have the following code: int MimeDocument::GetAttachmentId( std::string const& content_id ) { using namespace boost::lambda; using boost::lambda::_1; using boost::bind; int id = 0; std::vector<std::string>::iterator it = std::find_if( attachment_list_.begin(), attachment_list_.end(), bind( &std::string::find, content_id, _1 ) != std::string::npos ); if( it != attachment_list_.end() ) { id = std::distance( attachment_list_.begin(), it ); } return id; } Which when compiled on MSVC9 SP1

“No matching function for call to bind” while using websocketpp

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:16:02
问题 I'm making an (c++) application which is a websocket client and websocket server. To be able to do this, I'm using the library websocketpp. To make the application both a client and server, I want the endpoint1.run() and endpoint2.listen(port) to be multi-threaded. This is where something goes wrong. Normally (single thread) I use: endpoint.listen(port); which works. To make it into a multi-thread I use: boost::thread t(boost::bind(&server::listen, &endpoint, port)); sleep(1); cout << "After

Help with boost bind/functions

淺唱寂寞╮ 提交于 2019-12-11 05:17:31
问题 I have this function signature I have to match typedef int (*lua_CFunction) (lua_State *L);//target sig Here's what I have so far: //somewhere else... ... registerFunction<LuaEngine>("testFunc", &LuaEngine::testFunc, this); ... //0 arg callback void funcCallback0(boost::function<void ()> func, lua_State *state) { func(); } template<typename SelfType> void registerFunction(const std::string &funcName, boost::function<void (SelfType*)> func, SelfType *self) { //funcToCall has to match lua

How to use/manipulate return value from nested boost::bind

人走茶凉 提交于 2019-12-11 04:14:08
问题 I have two functions: 1. A & DataSource(); 2. void DataConsumer( A * ); What I want to achieve: Using one statement to assemble them into one functor . I have tried: 1. boost::function< void()> func( boost::bind( DataConsumer, & boost::bind( DataSource ) ) ); certainly it didn't work, compiler says it can not convert 'boost::_bi::bind_t ' to 'A *' 2. boost::function< void()> func( boost::bind( DataConsumer, boost::addressof( boost::bind( DataSource ) ) )); compiler says cannot convert

What is wrong with this boost::lambda::bind usage?

天涯浪子 提交于 2019-12-11 00:55:24
问题 Is there something wrong in this code? I keep getting compilation errors. Basically I want to connect a void returning function to a signal which has a non void return type. Boost version: Release 1.46.1 #include <boost/signals2.hpp> #include <boost/lambda/bind.hpp> #include <boost/lambda/lambda.hpp> using namespace boost::signals2; void func() { printf("Func called!"); } main() { signal<int(int)> sig; sig.connect( (boost::lambda::bind(func), 1) ); } I get the following error while compiling:

Problem with boost::bind, boost::function and boost::factory

别来无恙 提交于 2019-12-10 21:25:56
问题 I'm trying without success to use a boost::bind with a boost::factory I have this class Zambas with 4 arguments (2 strings and 2 ints) and class Zambas { public: Zambas(const std::string&, const std::string&,int z1=0,int z2=0) { if (z1==z2){ } } }; inside other method i have the following call boost::function<Zambas*()> f(boost::bind(boost::factory<Zambas*>(), std::string(""), std::string(""),_1,_2)); that fails with the following compiler error: bind.hpp:382: error: no match for ‘operator[]’

boost bind class function pointer

半城伤御伤魂 提交于 2019-12-10 19:48:26
问题 class Foo { double f1( int x, std::string s1 ); double f2( int x, SomeClass s2 ); } I want to be able to bind Foo.f1's s1 without an instance of foo to create in essense typedef double (Foo::* MyFooFunc)( int ) MyFooFunc func1 = boost::bind( &Foo::f1, _1, _2, "some string" ); MyFooFunc func2 = boost::bind( &Foo::f2, _1, _2, SomeClass ); Then I pass func1 and func2 as parameters to other functions, inside which Foo is finally bound: void SomeOtherFunction( MyFooFunc func ) { Foo foo; boost:

remove_if with boost::bind is slow

你离开我真会死。 提交于 2019-12-10 18:32:48
问题 I have a std::list of classes and want to remove entries that are marked for delete. I am using std::remove_if and erase. class MyClass { bool isDone(MyData& myData) { return myData.isDone(); } void removeIfDone(std::list<MyData>& myList) { std::list<MyData>::iterator it = remove_if(myList.begin(), myList.end(), boost::bind(&MyClass::isDone, this, _1)); myList.erase(it, myList.end()); } }; I am running on a small processor for which memory allocation and deallocation is very expensive. This