On Saturday, 4 April 2020 at 12:14:23 UTC, Robert M. Münch wrote:
On 2020-04-04 10:32:32 +, Ferhat Kurtulmuş said:
struct S {
float a;
float b;
S opOpAssign(string op)(ref S rhs) if (op == "+"){
this.a += rhs.a;
this.b += rhs.b;
return this;
On 4/4/20 8:45 AM, Steven Schveighoffer wrote:
>> Yes, sure, but in C++ I don't have to explicitly write this down. It
>> just works. IMO that makes a lot of sense as long as all types fit.
>> This just looks superfluously.
>>
>
> steves@homebuild:~$ cat test.cpp
> struct S
> {
> float a;
>
On 4/4/20 8:14 AM, Robert M. Münch wrote:
On 2020-04-04 10:32:32 +, Ferhat Kurtulmuş said:
struct S {
float a;
float b;
S opOpAssign(string op)(ref S rhs) if (op == "+"){
this.a += rhs.a;
this.b += rhs.b;
return this;
}
}
If the struct is
On 4/4/20 8:07 AM, Robert M. Münch wrote:
On 2020-04-04 10:32:32 +, Ferhat Kurtulmuş said:
Probably I didn't understand what you mean. Sorry if this is not the
case, but this one is easy.
...
struct S {
float a;
float b;
S opOpAssign(string op)(ref S rhs) if (op == "+"){
On Saturday, April 4, 2020 4:22:29 AM MDT Robert M. Münch via Digitalmars-d-
learn wrote:
> 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
On 2020-04-04 10:32:32 +, Ferhat Kurtulmuş said:
struct S {
float a;
float b;
S opOpAssign(string op)(ref S rhs) if (op == "+"){
this.a += rhs.a;
this.b += rhs.b;
return this;
}
}
If the struct is from some 3rd party source, how can I add
On 2020-04-04 10:32:32 +, Ferhat Kurtulmuş said:
Probably I didn't understand what you mean. Sorry if this is not the
case, but this one is easy.
...
struct S {
float a;
float b;
S opOpAssign(string op)(ref S rhs) if (op == "+"){
this.a += rhs.a;
this.b +=
On Saturday, 4 April 2020 at 10:22:29 UTC, Robert M. Münch wrote:
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?
Probably I
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
http://www.saphirion.com
smarter | better | faster