Re: Access derived type in baseclass static function template

2017-08-03 Thread Timoses via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 15:38:12 UTC, Steven Schveighoffer wrote: On 8/2/17 11:06 AM, Timoses wrote: On Wednesday, 2 August 2017 at 13:51:01 UTC, Steven Schveighoffer wrote: However, your original code has potential as an enhancement request, as the type is known at compile-time and coul

Re: Access derived type in baseclass static function template

2017-08-03 Thread Timoses via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 12:07:46 UTC, Timoses wrote: Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. [...] Created an enhancement issue: https://issues.dlang.org/show_bug.cgi?id=17714

Re: Access derived type in baseclass static function template

2017-08-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/2/17 11:06 AM, Timoses wrote: On Wednesday, 2 August 2017 at 13:51:01 UTC, Steven Schveighoffer wrote: However, your original code has potential as an enhancement request, as the type is known at compile-time and could certainly be resolved to pass in as the `this` template parameter. I

Re: Access derived type in baseclass static function template

2017-08-02 Thread Timoses via Digitalmars-d-learn
Thanks Arafel, the alias workaround might just be a nice way to put it. On Wednesday, 2 August 2017 at 13:51:01 UTC, Steven Schveighoffer wrote: What you are looking for is virtual static methods, and D doesn't have those. I don't know if there's a way to make it work with existing features.

Re: Access derived type in baseclass static function template

2017-08-02 Thread Arafel via Digitalmars-d-learn
What you are looking for is virtual static methods, and D doesn't have those. I don't know if there's a way to make it work with existing features. Well, there are interesting things to do: https://dpaste.dzfl.pl/ed826ae21473 I don't know if that's what one would call "virtual static",

Re: Access derived type in baseclass static function template

2017-08-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/2/17 9:11 AM, Timoses wrote: On Wednesday, 2 August 2017 at 12:49:12 UTC, Steven Schveighoffer wrote: Thanks for the reply! Not sure I understand correctly, though. interface I {} class A : I {} void test(T)(T t) if(is(T: I)) { writeln(T.type.stringof); } void main() { A.test; } t

Re: Access derived type in baseclass static function template

2017-08-02 Thread Arafel via Digitalmars-d-learn
On 08/02/2017 02:07 PM, Timoses wrote: Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. this T does not seem to be working, I guess because it's a static function and this does not exists?! [...] Any way I could

Re: Access derived type in baseclass static function template

2017-08-02 Thread Timoses via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 12:49:12 UTC, Steven Schveighoffer wrote: On 8/2/17 8:07 AM, Timoses wrote: Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. this T does not seem to be working, I guess because it's a stat

Re: Access derived type in baseclass static function template

2017-08-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/2/17 8:07 AM, Timoses wrote: Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. this T does not seem to be working, I guess because it's a static function and this does not exists?! Yep. Any way I could accomplish

Access derived type in baseclass static function template

2017-08-02 Thread Timoses via Digitalmars-d-learn
Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. this T does not seem to be working, I guess because it's a static function and this does not exists?! interface I { static void test(this T)() { writeln(

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 11:18:17 UTC, Daniel Kozak wrote: On Thursday, 7 May 2015 at 11:15:02 UTC, Daniel Kozak wrote: On Thursday, 7 May 2015 at 11:08:50 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:46:19 + Lemonfiend via Digitalmars-d-learn wrote: On Thursday, 7 May 2015 at 10

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 10:19:44 UTC, Lemonfiend wrote: Is it not possible to have a static function template with the same name as the non-static version? struct S { int i; auto foo(T)(int j) { i=j; } static auto foo(T)(int j) { S s; s.foo!T(j

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 11:08:50 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:46:19 + Lemonfiend via Digitalmars-d-learn wrote: On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak wrote: > On Thursday, 7 May 2015 at 10:39:09 UTC, Daniel Kozák wrote: >> >> On Thu, 07 May 2015 10:

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 11:15:02 UTC, Daniel Kozak wrote: On Thursday, 7 May 2015 at 11:08:50 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:46:19 + Lemonfiend via Digitalmars-d-learn wrote: On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak wrote: > On Thursday, 7 May 2015 at 1

Re: Static function template

2015-05-07 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 07 May 2015 10:46:19 + Lemonfiend via Digitalmars-d-learn wrote: > On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak wrote: > > On Thursday, 7 May 2015 at 10:39:09 UTC, Daniel Kozák wrote: > >> > >> On Thu, 07 May 2015 10:33:44 + > >> Vadim Lopatin via Digitalmars-d-learn > >

Re: Static function template

2015-05-07 Thread Lemonfiend via Digitalmars-d-learn
On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak wrote: On Thursday, 7 May 2015 at 10:39:09 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:33:44 + Vadim Lopatin via Digitalmars-d-learn wrote: struct S { int i; auto foo2(T)(int j) { i=j; } static S foo(T)(i

Re: Static function template

2015-05-07 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 7 May 2015 at 10:39:09 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:33:44 + Vadim Lopatin via Digitalmars-d-learn wrote: struct S { int i; auto foo2(T)(int j) { i=j; } static S foo(T)(int j) { S s; s.foo2!T(j); retu

Re: Static function template

2015-05-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 07, 2015 10:19:42 Lemonfiend via Digitalmars-d-learn wrote: > Is it not possible to have a static function template with the > same name as the non-static version? No. Unfortunately, you can't overload based on static. I believe that it works if they're overload

Re: Static function template

2015-05-07 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 07 May 2015 10:33:44 + Vadim Lopatin via Digitalmars-d-learn wrote: > struct S > { > int i; > > auto foo2(T)(int j) { > i=j; > } > > static S foo(T)(int j) { > S s; > s.foo2!T(j); > return s; > } > } > > void main() > {

Re: Static function template

2015-05-07 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 07 May 2015 10:19:42 + Lemonfiend via Digitalmars-d-learn wrote: > Is it not possible to have a static function template with the > same name as the non-static version? > > struct S > { > int i; > > auto foo(T)(int j) { > i=j; >

Re: Static function template

2015-05-07 Thread Vadim Lopatin via Digitalmars-d-learn
On Thursday, 7 May 2015 at 10:19:44 UTC, Lemonfiend wrote: Is it not possible to have a static function template with the same name as the non-static version? struct S { int i; auto foo(T)(int j) { i=j; } static auto foo(T)(int j) { S s; s.foo!T(j

Re: Static function template

2015-05-07 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 07 May 2015 10:19:42 + Lemonfiend via Digitalmars-d-learn wrote: > Is it not possible to have a static function template with the > same name as the non-static version? > > struct S > { > int i; > > auto foo(T)(int j) { > i=j; >

Static function template

2015-05-07 Thread Lemonfiend via Digitalmars-d-learn
Is it not possible to have a static function template with the same name as the non-static version? struct S { int i; auto foo(T)(int j) { i=j; } static auto foo(T)(int j) { S s; s.foo!T(j); return s; } } void main() { auto s = S.foo

Re: is there such a thing as a "static" function template that isn't inside of a class?

2011-07-17 Thread Jacob Carlborg
On 2011-07-16 23:34, Christopher the Magnificent wrote: I see this code AT THE TOP (MODULE) LEVEL of one of Michel Fortin's D/Objective-C bridge source files and I'm trying to wrap my head around it. /** Wrap an object instance within an object of this class. */ static Object objcCreateWrapper(T

is there such a thing as a "static" function template that isn't inside of a class?

2011-07-16 Thread Christopher the Magnificent
I see this code AT THE TOP (MODULE) LEVEL of one of Michel Fortin's D/Objective-C bridge source files and I'm trying to wrap my head around it. /** Wrap an object instance within an object of this class. */ static Object objcCreateWrapper(T)(id instance) {