Re: Normalize void

2018-07-10 Thread Mr.Bingo via Digitalmars-d
On Tuesday, 10 July 2018 at 13:28:42 UTC, Yuxuan Shui wrote: On Tuesday, 10 July 2018 at 11:37:25 UTC, ag0aep6g wrote: On 07/10/2018 11:56 AM, Yuxuan Shui wrote: Possible alternatives: * struct Void {}. Takes 1 byte, not as ideal * alias Void = AliasSeq!(). Doesn't work as template argument.

Re: Normalize void

2018-07-10 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 10 July 2018 at 11:37:25 UTC, ag0aep6g wrote: On 07/10/2018 11:56 AM, Yuxuan Shui wrote: Possible alternatives: * struct Void {}. Takes 1 byte, not as ideal * alias Void = AliasSeq!(). Doesn't work as template argument. i.e.   SomeTemplate!Void; // actually become

Re: Normalize void

2018-07-10 Thread ag0aep6g via Digitalmars-d
On 07/10/2018 11:56 AM, Yuxuan Shui wrote: Possible alternatives: * struct Void {}. Takes 1 byte, not as ideal * alias Void = AliasSeq!(). Doesn't work as template argument. i.e.   SomeTemplate!Void; // actually become SomeTemplate!() What about `void[0]`? It's a proper type. You can

Re: Normalize void

2018-07-10 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 10 July 2018 at 09:50:45 UTC, Yuxuan Shui wrote: Suppose I want to create a type to contain either a return value or an error, I could probably do something like this: [...] Breaking changes: void[] x; pragma(msg, x[0].sizeof); // now 0?

Re: Normalize void

2018-07-10 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 10 July 2018 at 09:50:45 UTC, Yuxuan Shui wrote: Suppose I want to create a type to contain either a return value or an error, I could probably do something like this: [...] Possible alternatives: * struct Void {}. Takes 1 byte, not as ideal * alias Void = AliasSeq!(). Doesn't

Normalize void

2018-07-10 Thread Yuxuan Shui via Digitalmars-d
Suppose I want to create a type to contain either a return value or an error, I could probably do something like this: struct Result(T, E) { bool is_err; union { T result; E error; } } This will probably work fine, unless I don't need an