Can Scope Be Used for Anonymous Objects?

Vijay Nayar madric at gmail.com
Wed Oct 17 20:54:50 UTC 2018


On Wednesday, 17 October 2018 at 20:51:29 UTC, Stanislav Blinov 
wrote:
> On Wednesday, 17 October 2018 at 20:24:56 UTC, Vijay Nayar 
> wrote:
>> I have a snippet of code like this:
>>     scope chordAngle = new S1ChordAngle(_center, 
>> other._center);
>>     return _radius + other._radius >= chordAngle;
>>
>> The reason the "scope" temporary variable exists is to avoid a 
>> heap allocation and instead prefer a value be created on the 
>> stack.  Is there a way to do this inline?
>
> Why, exactly, is a trivial thing like this even a class?

Porting C++ code which unfortunately makes heavy use of 
inheritance.  I originally had this as a struct until I much 
later stumbled into the other classes that were inheriting from 
it.


More information about the Digitalmars-d-learn mailing list