Languages for servers (Go, D, and more)

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 8 08:23:29 PDT 2014


On Tuesday, 8 July 2014 at 14:24:10 UTC, Sean Kelly wrote:
> On Tuesday, 8 July 2014 at 02:31:50 UTC, Átila Neves wrote:
>> On Monday, 7 July 2014 at 18:15:32 UTC, Sean Kelly wrote:
>>>
>>> With asynchronous event-driven code (ie. server code), I don't
>>> see any way to avoid all use of new / delete.
>>
>> std::make_unique and std::make_shared are what you're 
>> "supposed" to use. The new and delete operators are (usually) 
>> for library writers.
>> Even before C++11, using delete was frowned upon but necessary 
>> with containers of pointers due to std::auto_ptr not helping. 
>> Well, that and the lack of move semantics.
>
> But you're ultimately passing something as a void* to a library 
> call and receiving it later as the context for a callback.  
> That value has to live on the heap.

The point isn't that nothing lives on the heap in modern C++. 
It's that whatever does is wrapped in a class that manages the 
lifetime of the allocated memory for you.

Atila


More information about the Digitalmars-d mailing list