Struct no-arg constructor?

2012-07-25 Thread monarch_dodra
According to TDPL, the rationale for structs not having default constructors is "T.init", were T.init is defined as: *A static, known at compile time, mem-copyable value. *The value that gets mem-copied into structs before the constructors are called *The value that gets mem-copied into structs

Re: Struct no-arg constructor?

2012-07-25 Thread Jonathan M Davis
On Wednesday, July 25, 2012 11:34:12 monarch_dodra wrote: > According to TDPL, the rationale for structs not having default > constructors is "T.init", were T.init is defined as: > *A static, known at compile time, mem-copyable value. > *The value that gets mem-copied into structs before the > cons

Re: Struct no-arg constructor?

2012-07-25 Thread monarch_dodra
On Wednesday, 25 July 2012 at 09:51:49 UTC, Jonathan M Davis wrote: If you want to be able to do S(), then declare a static opCall for S which returns an S constructed in the way that you want. struct S { static S opCall() { //do whatever you do return s; } } auto s

Re: Struct no-arg constructor?

2012-07-25 Thread Simen Kjaeraas
On Wed, 25 Jul 2012 12:30:56 +0200, monarch_dodra wrote: I read TDPL back to back like 5 times before posting this, but it never mentions opCall. I just checked the index right now, it is not in there. Is this new? Hardly. Once upon a time, in the bad old days, structs didn't have constr

Re: Struct no-arg constructor?

2012-07-25 Thread deadalnix
Le 25/07/2012 12:30, monarch_dodra a écrit : On Wednesday, 25 July 2012 at 09:51:49 UTC, Jonathan M Davis wrote: If you want to be able to do S(), then declare a static opCall for S which returns an S constructed in the way that you want. struct S { static S opCall() { //do whatever you do retu

Re: Struct no-arg constructor?

2012-07-25 Thread deadalnix
Le 25/07/2012 11:51, Jonathan M Davis a écrit : On Wednesday, July 25, 2012 11:34:12 monarch_dodra wrote: According to TDPL, the rationale for structs not having default constructors is "T.init", were T.init is defined as: *A static, known at compile time, mem-copyable value. *The value that get

Re: Struct no-arg constructor?

2012-07-25 Thread monarch_dodra
On Wednesday, 25 July 2012 at 10:40:22 UTC, deadalnix wrote: Static opCall isn't a solution. You can't new on it. And it seems weird that you can disable something that don't possibly exists in the first place. This topic comes back again and again on the NG, it have to be considered. If I