mixin does not work as expected
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Jan 5 17:48:03 UTC 2022
On Wed, Jan 05, 2022 at 08:40:15AM +0000, rempas via Digitalmars-d-learn wrote:
[...]
> void test(bool signed)(int num, int base) {
> static if (signed) {
> mixin(type_check!("static if", "i8", "true", "5", "4", "10", "5"));
> mixin(type_check!("else static if", "i16", "true", "7", "6", "18",
> "8"));
> mixin(type_check!("else static if", "i32", "true", "12", "10", "34",
> "13"));
> mixin(type_check!("else", "i64", "true", "21", "18", "66", "24"));
> }
[...]
Yeah, this won't fly. Whatever you pass to mixin must be one or more
*complete* declaration or (possibly compound) statements. It's illegal
to pass the `static if` and its else-clause to two different mixin()
invocations (they are considered part of the same compound statement).
T
--
"No, John. I want formats that are actually useful, rather than over-featured megaliths that address all questions by piling on ridiculous internal links in forms which are hideously over-complex." -- Simon St. Laurent on xml-dev
More information about the Digitalmars-d-learn
mailing list