A comparison between C++ and D

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 9 15:19:18 PST 2016


On Wednesday, 9 March 2016 at 22:54:13 UTC, bigsandwich wrote:
> On Wednesday, 9 March 2016 at 22:05:28 UTC, Ola Fosheim Grøstad 
> wrote:
>> [...]
>
> Yes, I do.  std::function<> uses type erasure to store a 
> "function".  If its small enough, its stored internally, 
> otherwise it goes on the heap.  It uses RAII to manage the 
> lifetime of the lambda.  D is using the GC for managing the 
> lifetime.  D doesn't have a way of doing this without the GC.

D can do it too, there's just no syntactic sugar for it.

Atila


More information about the Digitalmars-d mailing list