小编use*_*773的帖子

将"this"参数显式传递给方法调用

是否有可能在c ++调用类方法中显式传递第一个"this"参数呢?

像这样的东西:

struct A
{
    void some() {} 
};

....

A a;
A::some(&a); // ~ a.some();
Run Code Online (Sandbox Code Playgroud)

对于合理的问题"为什么?":我需要实现std :: bind analogue,它适用于这样的结构:

void f(int);
bind(f, 3);
Run Code Online (Sandbox Code Playgroud)

但这不起作用:

bind(&A::some, &a);
Run Code Online (Sandbox Code Playgroud)

更新: 大家好,我的问题显然不是很清楚.我知道如何使用std :: bind,我想知道如何处理这个param显式传递给它的构造:std :: bind(&A :: some,&a);

c++ std c++11

6
推荐指数
1
解决办法
297
查看次数

标签 统计

c++ ×1

c++11 ×1

std ×1