No implicit opOpAssign for structs with basic types?

Robert M. Münch robert.muench at
Sat Apr 4 10:22:29 UTC 2020

D doesn't have implicit operators for structs?

struct S {float a, float b};
S a = {1, 5};
S b = {2, 5);

a += b;
Error: a is not a scalar, it is a S

So I really have to write an overloaded operator for such cases?

Robert M. Münch
smarter | better | faster

More information about the Digitalmars-d-learn mailing list