Re: Is there any performance penalty for static if?

2019-05-15 Thread user1234 via Digitalmars-d-learn
On Wednesday, 15 May 2019 at 22:03:39 UTC, Ferhat Kurtulmuş wrote: Hi, Maybe I already know the answer, but have to be sure about this. I am emulating this cpp code "int val = mat.at(row, col)" like: T at(T)(int row, int col){ static if (T.stringof == "float"){ return

Re: Is there any performance penalty for static if?

2019-05-15 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 15 May 2019 at 22:13:18 UTC, Jonathan M Davis wrote: On Wednesday, May 15, 2019 4:03:39 PM MDT Ferhat Kurtulmuş via Digitalmars- d-learn wrote: [...] If you really want to see what happens (for any piece of code), then you can look at the generated assembly, but static if is

Re: Is there any performance penalty for static if?

2019-05-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 15, 2019 4:03:39 PM MDT Ferhat Kurtulmuş via Digitalmars- d-learn wrote: > Hi, > > Maybe I already know the answer, but have to be sure about this. > I am emulating this cpp code "int val = mat.at(row, col)" > like: > > T at(T)(int row, int col){ > static if (T.stringof

Is there any performance penalty for static if?

2019-05-15 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
Hi, Maybe I already know the answer, but have to be sure about this. I am emulating this cpp code "int val = mat.at(row, col)" like: T at(T)(int row, int col){ static if (T.stringof == "float"){ return getFloatAt(row, col); } else static if (T.stringof ==

Re: Creating a RedBlackTree

2019-05-15 Thread Bogdan via Digitalmars-d-learn
On Wednesday, 15 May 2019 at 13:19:36 UTC, drug wrote: You can use predicate for this purpose: ``` auto rbt = redBlackTree!((a, b) => a.ID < b.ID, KeyController); ``` https://run.dlang.io/is/CNRTQf Even better, thank you!

Re: Creating a RedBlackTree

2019-05-15 Thread Bogdan via Digitalmars-d-learn
On Wednesday, 15 May 2019 at 13:15:50 UTC, Stefan Koch wrote: Key controller cannot be compared by less which is why it fails, give it an opCmp and it'll work. Works fine, thank you! For some reason, I thought that this template uses references: ``` enum KeyID: uint { KEY_A,

Re: Creating a RedBlackTree

2019-05-15 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 15 May 2019 at 13:08:18 UTC, Bogdan wrote: I don't have any experience with using templates. Is it possible to create a RB tree containing structs, where the nodes are ordered by one struct member? ``` import std.stdio; import std.container; enum KeyID: uint { KEY_A,

Re: Creating a RedBlackTree

2019-05-15 Thread drug via Digitalmars-d-learn
On 15.05.2019 16:08, Bogdan wrote: I don't have any experience with using templates. Is it possible to create a RB tree containing structs, where the nodes are ordered by one struct member? ``` import std.stdio; import std.container; enum KeyID: uint { KEY_A, KEY_S, KEY_D,    

Creating a RedBlackTree

2019-05-15 Thread Bogdan via Digitalmars-d-learn
I don't have any experience with using templates. Is it possible to create a RB tree containing structs, where the nodes are ordered by one struct member? ``` import std.stdio; import std.container; enum KeyID: uint { KEY_A, KEY_S, KEY_D, KEY_W } struct

Re: GtkD slows down visual D keyboard

2019-05-15 Thread Alex via Digitalmars-d-learn
A hack: On Tue, 14 May 2019 19:44:01 +0200, Mike Wey wrote: On 14-05-2019 05:10, Alex X wrote: Any news on this? https://forum.dlang.org/thread/bznpylcjostbrrwzh...@forum.dlang.org It's severely cramping my style ;/ Unfortunately no. // The following code bypasses GTK windows hooking

Re: CTFE in imported static initializers

2019-05-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/14/19 10:41 PM, Steven Schveighoffer wrote: OK, now that I have a compiler developer agreeing, I feel more comfortable filing ;) https://issues.dlang.org/show_bug.cgi?id=19874 -Steve

Re: Alias to template instance wokrs, but non-template does not?

2019-05-15 Thread Dukc via Digitalmars-d-learn
On Tuesday, 14 May 2019 at 14:36:21 UTC, Q. Schroll wrote: [snip] I've filed a bug report [1] some time ago. I'm posting here, because I want to understand what's going on here. I read through this post and while I don't know precisely what the compiler is thinking, it seems for me that your