digitalmars.D.learn - parametrize align
- noob-is-noob (25/25) May 20 2008 hi,
hi, _align(N)_ may be attributed to a struct, or a type inside a struct, but it seems that N must be a numeric literal, cannot be a const int, or template parameter. The following 3 cases all give : integer expected, not N 1: const int N ; align(N) struct S {} 2: align(N) struct S(int N = 4) {} 3: struct S(int N = 4) { byte a ; align(N) int b ; } but ok with a mixin: const string NN = "0123456789" ; struct S(int N = 4 ) { byte a ; mixin("align(" ~NN[N]~") int b ;"); } => S!(4).sizeof = 8 S!(1).sizeof = 5 How to do parametrized align without mixin?
May 20 2008