How to implement Stub in C++11

If you use the Lambda expression in C++11, more concise programming is possible, such as skipping class inheritance relationships, etc., through Lambda capture. Use the Lambda expression when you are implementing a stub, such as below.

  • Create a StubFunctional instance.
  • Define an RMI function you want to implement in StubFunctional in the form of a Lambda expression. If needed, use the PARAM_ macro.

Below is an example of implementing an RMI stub in a Lambda expression.

<exam.pidl>
Func1([in] int a, [in] string b);
<exam.cpp>
class Exam
{
int x = 1;
Exam::StubFunction examStub;
void Main()
{
int y = 3;
examStub.Func1_Function = [this, y]PARAM_Exam_Func1 {
x+=a;
y+=a;
return true;
};
}
};