digitalmars.D.learn - Checking if something is a template specialization?
- Sean Eskapp (10/10) Feb 17 2011 If I have
- Lars T. Kyllingstad (13/26) Feb 18 2011 void foo(Y)()
- Sean Eskapp (2/28) Feb 18 2011 Perfect, thanks!
If I have class Bar(T) { } void foo(Y)() { ... } Is there a way to check inside foo() that Y is in some way an instantiation of Bar? Is there a way to find WHICH instantiation it is?
Feb 17 2011
On Fri, 18 Feb 2011 02:02:51 +0000, Sean Eskapp wrote:If I have class Bar(T) { } void foo(Y)() { ... } Is there a way to check inside foo() that Y is in some way an instantiation of Bar? Is there a way to find WHICH instantiation it is?void foo(Y)() { static if (is(Y Z == Bar!Z)) { // Here, Z is now an alias to whichever type Bar is // instantiated with. } else { // Z is invalid here. } }
Feb 18 2011
== Quote from Lars T. Kyllingstad (public kyllingen.NOSPAMnet)'s articleOn Fri, 18 Feb 2011 02:02:51 +0000, Sean Eskapp wrote:Perfect, thanks!If I have class Bar(T) { } void foo(Y)() { ... } Is there a way to check inside foo() that Y is in some way an instantiation of Bar? Is there a way to find WHICH instantiation it is?void foo(Y)() { static if (is(Y Z == Bar!Z)) { // Here, Z is now an alias to whichever type Bar is // instantiated with. } else { // Z is invalid here. } }
Feb 18 2011