<div class="gmail_quote">On Mon, Apr 19, 2010 at 20:16, Ellery Newcomer <span dir="ltr"><<a href="mailto:ellery-newcomer@utulsa.edu">ellery-newcomer@utulsa.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello.<br>
<br>
Say I have a [struct] template T, which takes a param S.<br>
<br>
Any T!(S) satisfies a certain template constraint W, so I can use any T!(S) the same way. I want to be able to store heterogeneous T!(S) in a single list. Is there any good way to express the type for this?<br>
</blockquote></div><br>So, you have<br><br>struct S(T) {}<br><br>and W!(S!T)) is true, whatever T is. Right?<br><br>S!T is a type by itself, different from S!U, S!V, ... So I'm afraid there is no direct way to store them in an array. S by itself is not a type nor a struct, it's code waiting to be instantiated.<br>
<br>Maybe you could use Variant to hide the inner type away, and do an array of S!Variant. But then, there is no easy way to get back the type inside the variant.<br><br>Another solution is to use a TypeTuple or a Tuple:<br>
<br>import std.traits;<br>struct SList(Ss...) if (allSatisfy!(W, Ss))<br>{<br> Ss theList;<br>}<br><br>I'm using W as a predicate here.<br><br>Philippe<br><br>