Returning Anonymous Methods from Functions

Top  Previous  Next

New features since Delphi 7 > Anonymous Methods > Returning Anonymous Methods from Functions

 

Delphi

 

function MakeProc: TProcRef;

begin

  Result :=

    procedure

    begin

      DoSomething;

    end;

end;

 

C++ portable

 

TProcRef MakeProc()

{

TProcRef result;

result = [&]()

{

   DoSomething();

};

return result;

}

 

C++Builder

 

TProcRef MakeProc()

{

  return d2c::make_sysutils_callable<System::Sysutils::TProc, void()>(

    []()

    {

      DoSomething();

    });

}

 

 

The returned value contains the callable object.

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content