What was the thought behind making this
a pointer of T
, instead of T&&
?
For further actions, you may consider blocking this person and/or reporting abuse
What was the thought behind making this
a pointer of T
, instead of T&&
?
For further actions, you may consider blocking this person and/or reporting abuse
Ben Halpern -
Michelle Sanseverino -
Hanzla Baig -
Jasmeet Singh -
Top comments (6)
First, your question should really be: "Why is
this
a pointer instead of a reference?" (Note: that's reference and not rvalue reference.)The answer is simply because Bjarne invented
this
before he invented references.I know this is where the question answer ends, and speculation begins. But:
Do you think they would have made
this
a reference (possibly for safety reasons, possibly just for style) had they came up with references beforethis
?Probably; but at this point, I don't see why either my speculation or the question in general matters.
Yeah.. in hindsight, it was a very stupid question.
Member functions appeared in C++ long before rvalue references (C++11) and even just references. But in C++23 with Deducing this proposal, you can do the following:
This answer has nothing to do with the question.