Re: constructing labels for static foreach inside switch inside foreach

2020-07-07 Thread bauss via Digitalmars-d-learn
On Wednesday, 8 July 2020 at 02:06:01 UTC, Steven Schveighoffer wrote: OK, so I have a situation where I'm foreaching over a compile-time list of types. Inside the loop, I'm using a second loop over a set of input. Inside that loop, I'm using a switch on the input, and inside the switch, I'm

constructing labels for static foreach inside switch inside foreach

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
OK, so I have a situation where I'm foreaching over a compile-time list of types. Inside the loop, I'm using a second loop over a set of input. Inside that loop, I'm using a switch on the input, and inside the switch, I'm foreaching over the type's members, to construct a switch that can

How can I make DMD stop on the first fatal error? (-Wfatal-errors)

2020-07-07 Thread Marcone via Digitalmars-d-learn
How can I make DMD stop on the first fatal error like -Wfatal-errors on C++?

Re: Template function specialization doesn't work

2020-07-07 Thread Ali Çehreli via Digitalmars-d-learn
On 7/7/20 12:53 PM, IGotD- wrote: ubyte[3] ar = [ 1, 2, 3 ]; ubyte[] arSlice = ar; overloadedFunction(arSlice); The first function will be used. Shouldn't the template argument (T : T[]) make the compiler pick the second one? There is also template constraints which may be useful: import

Re: Template function specialization doesn't work

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 4:21 PM, IGotD- wrote: On Tuesday, 7 July 2020 at 20:14:19 UTC, IGotD- wrote: Thank you, that worked and now it picked the correct overloaded function. I don't understand why and it is a bit counter intuitive. Why two template arguments as I'm not even us using U? If you look at

Re: opApply and attributes

2020-07-07 Thread Ali Çehreli via Digitalmars-d-learn
On 7/6/20 5:20 PM, solidstate1991 wrote:> See implementation of data structure here: > https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/treemap.d#L565 > > > If I try to compile this code, it'll fail, limiting it's usecase: > > @safe pure unittest { > alias

Re: opApply and attributes

2020-07-07 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 13:33:41 UTC, Paul Backus wrote: You can make opApply a template: int opApply(Dg)(Dg dg) if (is(Dg : scope int delegate(ref E))) { // etc. } Because `scope int delegate(ref E) @safe` implicitly converts to `scope int delegate(ref E)`,

Re: Template function specialization doesn't work

2020-07-07 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 20:14:19 UTC, IGotD- wrote: Thank you, that worked and now it picked the correct overloaded function. I don't understand why and it is a bit counter intuitive. Why two template arguments as I'm not even us using U? If you look at the article

Re: Template function specialization doesn't work

2020-07-07 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 20:05:37 UTC, Steven Schveighoffer wrote: On 7/7/20 4:04 PM, Steven Schveighoffer wrote: Have you tried (T: U[], U)(ref T[] s) ? Ugh... (T: U[], U)(ref T s) -Steve Thank you, that worked and now it picked the correct overloaded function. I don't understand why

Re: Template function specialization doesn't work

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 4:04 PM, Steven Schveighoffer wrote: Have you tried (T: U[], U)(ref T[] s) ? Ugh... (T: U[], U)(ref T s) -Steve

Re: Template function specialization doesn't work

2020-07-07 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 19:53:30 UTC, IGotD- wrote: ... I also forgot to mention that the overloadedFunction is used in a variadic template function. void processAll(T...)(ref T t) { foreach(ref v; t) { overloadedFunction(v); } }

Re: Template function specialization doesn't work

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 3:53 PM, IGotD- wrote: I have two template functions void overloadedFunction(T)(ref T val) { } void overloadedFunction(T : T[])(ref T[] s) { } Obviously the second should be used when the parameter is a slice of any type, and the first should be used in other cases.

Template function specialization doesn't work

2020-07-07 Thread IGotD- via Digitalmars-d-learn
I have two template functions void overloadedFunction(T)(ref T val) { ... } void overloadedFunction(T : T[])(ref T[] s) { ... } Obviously the second should be used when the parameter is a slice of any type, and the first should be used in other cases. However this doesn't

Re: How to specify a version from dub build command

2020-07-07 Thread mw via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 06:34:15 UTC, adnan338 wrote: I have a separate version for flatpak builds in my app. Let's say I have a large project that builds with dub that goes like this: import std.stdio; void main() { version (flatpak) { writeln(`Flatpak build`);

Re: opApply and attributes

2020-07-07 Thread Stanislav Blinov via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 13:33:41 UTC, Paul Backus wrote: You can make opApply a template: int opApply(Dg)(Dg dg) if (is(Dg : scope int delegate(ref E))) { // etc. } Because `scope int delegate(ref E) @safe` implicitly converts to `scope int delegate(ref E)`,

Re: Catching OS Exceptions in Windows using LDC

2020-07-07 Thread realhet via Digitalmars-d-learn
On Saturday, 4 July 2020 at 14:44:06 UTC, Kagamin wrote: try https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setunhandledexceptionfilter Thank You, this was the winner for me. Not just I can catch the OS Exceptions, I can check and alter the CPU state and

Re: opApply and attributes

2020-07-07 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 00:20:40 UTC, solidstate1991 wrote: See implementation of data structure here: https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/treemap.d#L565 If I try to compile this code, it'll fail, limiting it's usecase: @safe pure unittest {

Re: BetterC Bug? Intended Behavior? Asking Here As Unsure

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 8:26 AM, Steven Schveighoffer wrote: On 7/6/20 5:09 PM, kinke wrote: On Monday, 6 July 2020 at 20:25:11 UTC, Kayomn wrote: Though, admittedly I'm kind of used to seeing this error message since it appears any time you try and do something that relies on type info in betterC,

Re: Construct an used-defined hash table container type from an AA-literal expression

2020-07-07 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 6 July 2020 at 12:04:11 UTC, Jacob Carlborg wrote: void main() @nogc { auto a = tuple(Pair("foo", 1), Pair("bar", 2)); } -- /Jacob Carlborg Thanks. What about construction and assignment from a static array of `Pair`'s? Wouldn't that be easier on the compiler?

Re: BetterC Bug? Intended Behavior? Asking Here As Unsure

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/6/20 5:09 PM, kinke wrote: On Monday, 6 July 2020 at 20:25:11 UTC, Kayomn wrote: Though, admittedly I'm kind of used to seeing this error message since it appears any time you try and do something that relies on type info in betterC, intentionally or not. A notable example is forgetting

Re: Associative array on the heap

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 3:08 AM, mw wrote: On Tuesday, 19 May 2015 at 12:21:48 UTC, Steven Schveighoffer wrote: On 5/18/15 7:55 PM, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can

Re: dub build=ddox, where the are the docs?

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/6/20 5:04 PM, claptrap wrote: Ok yeah it starts up a server and opens a webpage, great, but where are the docs? Cant find any info on command line switches for dub or ddox on how to get it to just dump the docs in a folder. dub --build=ddox makes a server and runs it so you can serve

Re: I need an Easy example to understand Alias This

2020-07-07 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 00:35:38 UTC, Marcone wrote: Hi, I study Dlang for one year, and I can't understand alias this. I need an Easy example to understand Alias This. I used it for widget inheritance in my experimental code here,

Re: I need an Easy example to understand Alias This

2020-07-07 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 00:44:32 UTC, Marcone wrote: On Tuesday, 7 July 2020 at 00:42:40 UTC, Ali Çehreli wrote: On 7/6/20 5:35 PM, Marcone wrote: Hi, I study Dlang for one year, and I can't understand alias this. I need an Easy example to understand Alias This. Is the following example

Re: Associative array on the heap

2020-07-07 Thread mw via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 12:21:48 UTC, Steven Schveighoffer wrote: On 5/18/15 7:55 PM, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can only create structs, dynamic

How to specify a version from dub build command

2020-07-07 Thread adnan338 via Digitalmars-d-learn
I have a separate version for flatpak builds in my app. Let's say I have a large project that builds with dub that goes like this: import std.stdio; void main() { version (flatpak) { writeln(`Flatpak build`); } else { writeln("Edit source/app.d