digitalmars.D.learn - Strange behaviour in templates (Another bug?)
- Tobias Pankrath (19/24) Nov 11 2011 I'm trying to learn template meta programming in D. To do this, I'm work...
I'm trying to learn template meta programming in D. To do this, I'm working on a meta state machine like Boost.MSM (http://www.boost.org/doc/libs/1_47_0/libs/msm/doc/HTML/index.html). States are types and can have sub states. If they do, they need to have an attribut 'SubStates', which should be a TypeTuble with the sub states. The task at hand is: Given a State and a list of all States, create a list of all parents of State including State itself. This code (http://paste.pocoo.org/show/506154/) ought to do this and it works sometimes. You can make to interesting observations of this code: In its current form, 'dmd test.d -unittest' will print: "falseBut if you uncomment the first pragma() in the unittest block, it will print() trueIf you change the body of ParentsDesc toalias TypeTuple!() Result;it will also printtrueAlthough the static if in ParentsDesc is never true in this example. What's going on?
Nov 11 2011