digitalmars.D.learn - Finding out if T is a specialization of another template
- Sean Eskapp (16/16) Feb 18 2011 I was given this code, to check if Y is a specialization of Bar. How doe...
- Lars T. Kyllingstad (5/24) Feb 18 2011 I'm not sure what you mean by "how does it work". If it's the is()
- Sean Eskapp (4/28) Feb 18 2011 Ah, yes. I'd checked the is documentation, but whenever I tried using th...
- Lars T. Kyllingstad (4/32) Feb 18 2011 Yeah, is() has a few extra features when it's combined with 'static
I was given this code, to check if Y is a specialization of Bar. How does it work? class Bar(T) { } 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
On Fri, 18 Feb 2011 17:16:02 +0000, Sean Eskapp wrote:I was given this code, to check if Y is a specialization of Bar. How does it work? class Bar(T) { } 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. } }I'm not sure what you mean by "how does it work". If it's the is() expression you're wondering about, it's documented here: http://www.digitalmars.com/d/2.0/expression.html#IsExpression -Lars
Feb 18 2011
== Quote from Lars T. Kyllingstad (public kyllingen.NOSPAMnet)'s articleOn Fri, 18 Feb 2011 17:16:02 +0000, Sean Eskapp wrote:Ah, yes. I'd checked the is documentation, but whenever I tried using that is expression outside of an if statement, it complained about my usage, so I assumed it had something to do with if statements.I was given this code, to check if Y is a specialization of Bar. How does it work? class Bar(T) { } 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. } }I'm not sure what you mean by "how does it work". If it's the is() expression you're wondering about, it's documented here: http://www.digitalmars.com/d/2.0/expression.html#IsExpression -Lars
Feb 18 2011
On Fri, 18 Feb 2011 20:37:38 +0000, Sean Eskapp wrote:== Quote from Lars T. Kyllingstad (public kyllingen.NOSPAMnet)'s articleYeah, is() has a few extra features when it's combined with 'static if'. :) -LarsOn Fri, 18 Feb 2011 17:16:02 +0000, Sean Eskapp wrote:Ah, yes. I'd checked the is documentation, but whenever I tried using that is expression outside of an if statement, it complained about my usage, so I assumed it had something to do with if statements.I was given this code, to check if Y is a specialization of Bar. How does it work? class Bar(T) { } 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. } }I'm not sure what you mean by "how does it work". If it's the is() expression you're wondering about, it's documented here: http://www.digitalmars.com/d/2.0/expression.html#IsExpression -Lars
Feb 18 2011