Assigning an Anonymous Method

Top  Previous  Next

New features since Delphi 7 > Anonymous Methods > Assigning an Anonymous Method

 

 

Delphi

 

var

  p: TProcRef;

begin

  p :=

    procedure

    begin

      DoSomething;

    end;

end;

 

C++ portable

 

TProcRef p;

p = [&]()

{

  DoSomething();

};

 

 

C++Builder

 

TProcRef p =

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

    [&]()

    {

      DoSomething();

    });

 

The lambda captures variables from the surrounding scope as needed.

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content