various questions
Jason Spencer
spencer8 at sbcglobal.net
Wed Jul 28 15:32:24 PDT 2010
== Quote from bearophile (bearophileHUGS at lycos.com)'s article
Thanks for all the suggestions!
A little more discussion:
> > So I need some slick way of mapping the run-time element size, row count,
> > and column count into a static array type to instantiate my template with.
> A basic brutal way to do that is to use a switch, that switches according to the
runtime value to use the correctly compile-time instantiated template. If the switch
becomes too much large you can use a string mixin to shrink it to few lines.
I had thought of the switch, and it would be too large. Can you give me an idea of what
the mixin solution would look like? Suppose I have three strings, type, rows, and cols
that get set at runtime, where type = ["int" | "float" | "short"], rows and cols =
["100" | "200" | "250"]. What I want is to take these 3 variables and come up with:
foo!(int[100][100])(...)
foo!(int[100][200])(...)
...
foo!(short[250][250])(...)
for the right cases, without switching on type, rows, or cols.
Thanks again.
Jason
More information about the Digitalmars-d-learn
mailing list