Show newer

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.

Show thread

I did not realize Neon White was a dating sim visual novel but here we are

my biggest criticism of javascript is that it was made by Brandon Eich

I am normal and can be trusted with twenty six dollars and seventy one cents

the nvidia installer is consistently crashing my pc.......

thank you nvidia installer for trying to install the nvidia app i didn't ask for

Show thread

thank you nvidia installer for my crashing my computer

Show thread

thank you nvidia for hiding drivers behind a slow ass UI so they can't be found from a search engine, so that the only easy wat to find the specific driver is to download your fucking app

I'm gonna Neon White because it's already in my library

I need something twitchy/technical to play, I've played a lot of cerebral games lately. Any recommendations

I tried to open fortnite for the first time in months and it crashed so hard my pc restarted

my computer tried to protect me. i will listen to it

In case you weren't aware Fallout 1 and 2 are available on steam in a $5 bundle right now

Show older
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.