Why doesn't `opAssign` work for my templated struct?
monkyyy
crazymonkyyy at gmail.com
Fri Nov 8 22:13:19 UTC 2024
On Friday, 8 November 2024 at 21:55:53 UTC, Liam McGillivray
wrote:
> if(isNumeric!T)
> ```
> Error: cannot implicitly convert expression `40.0F` of type
> `float` to `Milligrams`
> ```
I dont believe phoboes type detection templates are well
designed; given some sort of type pattern matching issue you
should write your own with the pattern
```
void dummyNumbericFunction(T)(T t){
auto foo=t+t;
...
}
enum isNumbertic(T)=__traits(compiles,dummyNumbericFunction!T);
```
More information about the Digitalmars-d-learn
mailing list