hey @coriander is this how you met yukon
https://x.com/gatinarios/status/1956147899357712862
re: Neon White
like is this not an insane place to hide something
https://www.youtube.com/watch?v=ghGZ0Ji1H2U
violence, gore
Hi all I just discovered the greatest thing ever:
https://youtu.be/GOnwBq0hBZY
violence, gore
Hi all I just discovered the greatest thing ever:
https://youtu.be/GOnwBq0hBZY
Hi @vaporeon_, a while ago we talked about the fact that references were introduced to C++ in order to enable operator overloading. You asked why you have to introduce references to enable this and I said that you didn't and it was an unnecessary complication.
I've been thinking about this and I don't agree anymore.
In C++, operators used with class types are syntactic sugar for method calls:
#include <iostream>
class NumWrapper {
public:
int val;
NumWrapper(int n) : val(n) {}
NumWrapper operator+(NumWrapper& r) { return NumWrapper(this->val + r.val); }
};
int main() {
NumWrapper l(3);
NumWrapper r(4);
std::cout << (l + r).val << "\n";
std::cout << l.operator+(r).val << "\n";
}
So why not make the overload method take pointers instead?
class NumWrapper {
public:
int val;
NumWrapper(int n) : val(n) {}
// why didn't c++ implement operator overloads like this?
NumWrapper operator+(NumWrapper* r) { return NumWrapper(this->val + r->val); }
};
Well, imagine we used an rvalue as one of the +
operands. Then a pointer to an rvalue would be passed to the overload function. rvalues normally have their addresses hidden from the programmer (you can't give them to &
). Then operator overloading would circumvent this feature and allow the programmer to access the address of an rvalue.
I currently believe that references were introduced so that C++ could have a pointer-like language construct that does not expose the addresses of rvalues.
this might be worse than when disco elysium called me The World's Most Laughable Centrist how could this happen to me.
kept afloat by big ideas.
you can call me Caleb or Clodsire. i also go by clodboy and catwin. i am not picky about names (unless its one amy made up)
videogame enjoyer. mathematics hobbyist and recovering physicist. software engineer. professional wonk. prophet of The Truth. the walking embodiment of "not diagnosed, but somethings wrong". undefeated fat cock award recipient. i like animals that wear cowboy hats.
pfp is by @The_T
header is by @vaporeon_
"i regret ever allowing him here" ~aescling
"oh you're one of those weird movie likers" ~Ti
"i know your taste in movies well enough to discount your opinion" ~globin
"caleb is the only person on this websites who truly understands what the report button is for: 'i don't like this post'" ~holly
30+
straight
he/him