boost-function

    1熱度

    1回答

    實現無操作仿函數我有一個函數void get(boost::function<void(void)> callback) { callback(); }。 我想撥打電話get(boost::bind(/* don't know what to put here*/));而不實施任何其他功能,變量或結構,以免回調無效。 是否有可能在C++ 03中實現這樣的「no-op」回調? boost::bind

    4熱度

    1回答

    我想使用boost預處理器來聲明具有不同模板變量長度的模板類,基本上就像boost :: function所做的那樣。 #if !BOOST_PP_IS_ITERATING #ifndef D_EXAMPLE_H #define D_EXAMPLE_H #include <boost/function> #include <boost/preprocessor/iteration/ite

    1熱度

    1回答

    最近我試圖創建靈活的觀察者模式實現,它隱藏了boost::signal。我幾乎成功了。 我有一個Observer類,它必須有一個update方法匹配模板參數提供的簽名。使用 例子: Observable<void(float, float)> observable; Observer<void(float, float)> observer; observable.attach(&observ

    24熱度

    1回答

    使用boost-bind,結果boost-function可能會接收比綁定對象所期望的更多參數。從概念上講: int func() { return 42; } boost::function<int (int,int,int)> boundFunc = boost::bind(&func); int answer = boundFunc(1,2,3); 在這種情況下,接收func() 1

    0熱度

    1回答

    我得到一些編譯時錯誤,我不明白這是爲什麼。下面的代碼將拒絕編譯,讓我有以下錯誤: 錯誤C2664: '無效(的PyObject *,爲const char *,提振::類型*)':無法從「常量字符轉換參數1 * 'to'PyObject *' error C2664:'void(PyObject *,const char *,boost :: type *)':無法將參數3從'boost :: s

    3熱度

    2回答

    class Foo { double f1(int x, std::string s1); double f2(int x, SomeClass s2); } 我希望能夠綁定Foo.f1的S1,而不富的一個實例,在essense typedef double (Foo::* MyFooFunc)(int) MyFooFunc func1 = boost::bind(

    2熱度

    1回答

    class User { public: User(){} virtual ~User(){} void Test(int in) { } } User user; vector< boost::function< void() > > functions; functions.push_back(boost::b

    1熱度

    2回答

    我想創建一個異步。服務器。 我成功地做到了這一點,但現在我想將async_read/asyn_write函數綁定到調用者對象函數。所以我試圖做到這一點與升壓::功能 在這裏你有我的代碼: Server.cpp #include "Server.h" #include "Client.h" #include "Network.h" void Server::accept(void) {

    2熱度

    1回答

    雖然試圖熟悉boost,但偶然發現使用boost::function以及std::vector的問題。我試圖做一件簡單的事情:有一個與similair簽名功能列表,然後在樣本數據上使用std::for_each的所有功能。下面是代碼: typedef boost::function<int (const char*)> text_processor; typedef std::vector<te

    2熱度

    1回答

    我想從DLL加載特定函數並將其存儲在Boost函數中。這可能嗎? typedef void (*ProcFunc) (void); typedef boost::function<void (void)> ProcFuncObj; ACE_SHLIB_HANDLE file_handle = ACE_OS::dlopen("test.dll", 1); ProcFunc func = (Pr