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