On 7/10/20 3:31 AM, psycha0s wrote:
On Thursday, 9 July 2020 at 22:18:59 UTC, Steven Schveighoffer wrote:
Looking at the generated AST, it's because the compiler is adding an
auto-generated opAssign, which accepts a Foo by value. It is that
object that is being created and destroyed.
Is there
On Thursday, 9 July 2020 at 22:18:59 UTC, Steven Schveighoffer
wrote:
Looking at the generated AST, it's because the compiler is
adding an auto-generated opAssign, which accepts a Foo by
value. It is that object that is being created and destroyed.
Is there a reason the autogenerated opAssign
On 7/9/20 6:08 PM, psycha0s wrote:
import std.stdio;
struct Foo {
int value;
this(int n)
{
value = n;
writeln("constuctor ", &this);
}
~this()
{
writeln("destuctor ", &this);
}
this(ref return scope Foo other)
{
I just didn't expect that the address of a "this" reference may
change.
I was learning copy constructors and got a really weird result.
It looks like a copy constructor and a destuctor of two unknown
objects are called. Could somebody please explain it to me?
import std.stdio;
struct Foo {
int value;
this(int n)
{
value =