parametrize align
noob-is-noob
noob at gmail.com
Tue May 20 00:32:14 PDT 2008
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?
More information about the Digitalmars-d-learn
mailing list