« first day (1534 days earlier)      last day (1302 days later) » 

3:15 AM
Hey guys, I read this article. Can someone tell me why this does not invoke a move ctor?
 
 
3 hours later…
6:02 AM
@d4rk4ng31 because there's a user-defined copy constructor, so the move constructor is not defaulted
 
6:31 AM
@PeterT Oh! Else, it would have called the move ctor right?
 
probably, try it out by explicitly defaulting it with S(S&&)=default;
 
Hmm... okay :)
@PeterT
 
well that might be a case of copy-elision
 
How?
We do not have 2 classes
Oh! Wait no
Copy elision
Yeah sorry
Mixed it up with object slicing
Hmm... Are you sure its that ?
 
I think you can disable copy elision with a flag
 
6:39 AM
Lemme check
-fno-elide-constructors
Is that it?
@PeterT?
Also, visual studio is being weird
It is not even recognising s as an object
 
well that's explained in the thread you linked about it being a cas of the most vexing parse
it's parsing it as a function declaration
warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]

    S s(S());

       ^~~~~

<source>:16:9: note: add a pair of parentheses to declare a variable

    S s(S());

        ^

        (  )

1 warning generated.
 
Hmm... but GCC isn't
 
gcc may not be warning you, but it still has to conform to the same parsing rules
 
Yeah, right! Okay Thanks a lot :)
 
6:54 AM
if you try to call a function on it, it'll tell you that it interpreted it as a function
request for member 'a' in 's', which is of non-class type 'S(S (*)())'

   18 |     s.a();

      |       ^
 
Yeah
It does
 

« first day (1534 days earlier)      last day (1302 days later) »