Compile time data structure
Ali Çehreli
acehreli at yahoo.com
Tue Sep 17 18:24:37 PDT 2013
On 09/16/2013 01:24 PM, Marek Janukowicz wrote:
> static string[string] columns () {
// ...
> }
Although the function itself is static, it returns a dynamic value.
> foreach( attr, col; columns() ) {
> __traits(getMember, me, attr) = typeof(__traits(getMember, me,
> attr)).init;
> }
That foreach is a run-time foreach because columns()'s return value is a
run-time value.
As far as I know, static foreach is only for tuples (or TypeTuples). If
you can generate the AA as a tuple, then the foreach will be evaluated
at compile time.
Ali
More information about the Digitalmars-d-learn
mailing list