3 ms·
Yeah Metaclasses in Python are obviously so powerful and make programs so easy to read, so let's just go ahead and add those as well. Now we only write st
by jstimpfle 9y ago
Yeah Metaclasses in Python are obviously so powerful and make programs so easy to read, so let's just go ahead and add those as well.
Now we only write
struct Point {
int x;
int y;
};
to get the oh-so-needed
class Point {
private:
int x;
int y;
public:
Point() =default;
~Point() noexcept =default;
Point(const Point&) =default;
Point& operator=(const Point&) =default;
Point(Point&&) =default;
Point& operator=(const Point&&) =default;
};
Genius! Almost like 1972 where we wrote the former and that was just fine!
- mattnewport 9y agoYou can still write the former and it's just fine.
- jstimpfle 9y agoExcept, I need to think the latter?
- mattnewport 9y agoNot for a Plain Old Data (POD) type. You need to think about the latter if you're manually managing memory or OS resources in your class (which should be rare) or you're trying to optimize performance when you have members that can be moved more cheaply than copied (usually because they manage memory) which should also usually be rare and the result of identifying a performance issue through profiling.