Re: Creating a template mixin for explicit casts.

2018-05-17 Thread Sjoerd Nijboer via Digitalmars-d-learn
On Thursday, 17 May 2018 at 20:38:13 UTC, Sjoerd Nijboer wrote: But then how do you put this into a mixin template so I can ... mixin castingRules(typeof(this) T); I guess I can refine my question to "How do you let a mixin template detect the template name it is instantiated with and

Re: Creating a template mixin for explicit casts.

2018-05-17 Thread Sjoerd Nijboer via Digitalmars-d-learn
On Thursday, 17 May 2018 at 16:27:48 UTC, Paul Backus wrote: On Thursday, 17 May 2018 at 15:25:37 UTC, Sjoerd Nijboer wrote: I want to make a template mixin that is able to cast one of these generic structs to the other explicitly. I have a bunch of these structs and therefore I thought it woul

Re: Creating a template mixin for explicit casts.

2018-05-17 Thread Meta via Digitalmars-d-learn
On Thursday, 17 May 2018 at 15:25:37 UTC, Sjoerd Nijboer wrote: Given the following code `struct Foo(T) if(isNumeric!T) { T t; .. other code } struct Bar(T) if(isNumeric!T) { T t; .. other code } Foo!float foo_float; Foo!double foo_double; Bar!f

Re: Creating a template mixin for explicit casts.

2018-05-17 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 17 May 2018 at 15:25:37 UTC, Sjoerd Nijboer wrote: I want to make a template mixin that is able to cast one of these generic structs to the other explicitly. I have a bunch of these structs and therefore I thought it would make sense to do it by template mixin. I just don't know wh

Creating a template mixin for explicit casts.

2018-05-17 Thread Sjoerd Nijboer via Digitalmars-d-learn
Given the following code `struct Foo(T) if(isNumeric!T) { T t; .. other code } struct Bar(T) if(isNumeric!T) { T t; .. other code } Foo!float foo_float; Foo!double foo_double; Bar!float bar_float; ` I want to make a template mixin that is able t