On Fri, Feb 1, 2013 at 11:04 PM, Christian Köstlin <christian.koest...@gmail.com> wrote: > Hi Philippe, > > wonderful solution. I also added > T get(T)() { > return components[staticIndexOf!(T, Children)]; > } > to the class to get the Children out by type (works as long as there is only > one child of each type in the tuple).
Indeed, that's easier for the user this way. In that case, you might want to either return a tuple of one or more type (when there is more than one of a given type) or put a restriction on Components so it's only a set of types. Maybe with: ... if(NoDuplicates!(Children).length == Children.length) See http://dlang.org/phobos/std_typetuple.html#.NoDuplicates Then, when you're feeling masochistic, the next step is to allow assignments from other Components with a permutation of children, because Component!(int,double) is not much different from Components!(double, int) :)