mixin does not work as expected
vit
vit at vit.vit
Wed Jan 5 09:02:53 UTC 2022
On Wednesday, 5 January 2022 at 08:40:15 UTC, rempas wrote:
> I'm trying to use mixins and enums to "expand" code in place
> but the results are not what I expected and I'm getting an
> weird error. I have created the smallest possible example to
> reproduce the error and it is the following:
>
> [...]
Try this:
```d
pragma(msg, type_check!("static if", "i8", "true", "5", "4",
"10", "5"));
```
Result:
```d
static if(is_same!(num, i8)) {
mixin(base_digit!("5", "4", "10", "5"));
static if (true) {
mixin(overflow_check!"i8.min"); }
}
```
is_same - is undefined
i8 - is undefined
overflow_check!"i8.min" - ?
This code with mixins is horrible :)
More information about the Digitalmars-d-learn
mailing list