Skip to content

Instantly share code, notes, and snippets.

@Unknown6656
Last active February 27, 2022 21:17
Show Gist options
  • Save Unknown6656/f2f7dc5038f3828a088373d510051829 to your computer and use it in GitHub Desktop.
Save Unknown6656/f2f7dc5038f3828a088373d510051829 to your computer and use it in GitHub Desktop.
CPP IS FUCKING RETARDED
// Use this include if you have a class with const members and have
// trouble using the assign or copy constructor. Thank me later.
//
// Example:
// class A {
// const int X, Y;
//
// A() : A(0, 0) { }
// A(int x, int y) : X(x), Y(y) { }
//
// CPP_IS_FUCKING_RETARDED(A);
// };
//
#pragma once
#define CPP_IS_FUCKING_RETARDED(x) inline x& operator =(const x& value) noexcept { return this == &value ? *this : *new(this)x(value); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment