Structs are Not Plain: A call for empty struct constructors

Andrea Fontana nospam at
Fri Sep 20 07:53:00 UTC 2019

On Friday, 20 September 2019 at 07:24:11 UTC, Max Samukha wrote:
> On Friday, 20 September 2019 at 06:01:00 UTC, Jonathan M Davis 
> wrote:
>> The issue of whether with allows you to construct a temporary 
>> that's valid for the entire scope of the with block is a 
>> separate issue from whether D should be altered to have 
>> default constructors. The OP just happened to use it in their 
>> example, and it does currently seem to work even if the spec 
>> is silent on the matter. Whether it ever gets changed to not 
>> work or the spec gets updated to define its behavior is 
>> irrelevant to the issue of default constructors.
>> - Jonathan M Davis
> Ok, I agree that the unspecified copy elision semantics is a 
> separate issue.

I wonder why nobody suggest something like this:

class MyClass {}

struct Fixture
   int i;
   immutable MyClass c;

auto fixture()
   Fixture ret =
     i : 10,
     c : new MyClass()

   return ret;

void main()



More information about the Digitalmars-d mailing list