- defaulted constructors and assignment operators of several trivial types.

This commit is contained in:
Christoph Oelckers 2018-08-25 23:51:07 +02:00
parent 0c4e6f88a6
commit 5b7d3c91f9
14 changed files with 40 additions and 149 deletions

View File

@ -468,7 +468,7 @@ public:
TObjPtr<AActor*> MUSINFOactor = nullptr; // For MUSINFO purposes TObjPtr<AActor*> MUSINFOactor = nullptr; // For MUSINFO purposes
int8_t MUSINFOtics = 0; int8_t MUSINFOtics = 0;
bool settings_controller = false; // Player can control game settings. bool settings_controller = true; // Player can control game settings.
int8_t crouching = 0; int8_t crouching = 0;
int8_t crouchdir = 0; int8_t crouchdir = 0;

View File

@ -167,22 +167,19 @@ class TObjPtr
DObject *o; DObject *o;
}; };
public: public:
TObjPtr() throw() TObjPtr() = default;
{ TObjPtr(const TObjPtr<T> &q) = default;
}
TObjPtr(T q) throw() TObjPtr(T q) throw()
: pp(q) : pp(q)
{ {
} }
TObjPtr(const TObjPtr<T> &q) throw() T operator=(T q)
: pp(q.pp)
{ {
pp = q;
return *this;
} }
T operator=(T q) throw()
{
return pp = q;
// The caller must now perform a write barrier.
}
operator T() throw() operator T() throw()
{ {
return GC::ReadBarrier(pp); return GC::ReadBarrier(pp);

View File

@ -103,7 +103,7 @@ enum
struct PalEntry struct PalEntry
{ {
PalEntry () {} PalEntry() = default;
PalEntry (uint32_t argb) { d = argb; } PalEntry (uint32_t argb) { d = argb; }
operator uint32_t () const { return d; } operator uint32_t () const { return d; }
void SetRGB(PalEntry other) void SetRGB(PalEntry other)
@ -146,6 +146,7 @@ struct PalEntry
{ {
return (d & 0xffffff) == 0xffffff; return (d & 0xffffff) == 0xffffff;
} }
PalEntry &operator= (const PalEntry &other) = default;
PalEntry &operator= (uint32_t other) { d = other; return *this; } PalEntry &operator= (uint32_t other) { d = other; return *this; }
PalEntry InverseColor() const { PalEntry nc; nc.a = a; nc.r = 255 - r; nc.g = 255 - g; nc.b = 255 - b; return nc; } PalEntry InverseColor() const { PalEntry nc; nc.a = a; nc.r = 255 - r; nc.g = 255 - g; nc.b = 255 - b; return nc; }
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
@ -205,7 +206,7 @@ class FTextureID
friend void R_InitSpriteDefs(); friend void R_InitSpriteDefs();
public: public:
FTextureID() throw() {} FTextureID() = default;
bool isNull() const { return texnum == 0; } bool isNull() const { return texnum == 0; }
bool isValid() const { return texnum > 0; } bool isValid() const { return texnum > 0; }
bool Exists() const { return texnum >= 0; } bool Exists() const { return texnum >= 0; }

View File

@ -399,7 +399,6 @@ void GLHorizonPortal::DrawContents(HWDrawInfo *hwdi)
Clocker c(PortalAll); Clocker c(PortalAll);
FMaterial * gltexture; FMaterial * gltexture;
PalEntry color;
player_t * player=&players[consoleplayer]; player_t * player=&players[consoleplayer];
GLSectorPlane * sp = &origin->plane; GLSectorPlane * sp = &origin->plane;
auto &vp = di->Viewpoint; auto &vp = di->Viewpoint;

View File

@ -228,7 +228,6 @@ int LevelAABBTree::GenerateTreeNode(int *lines, int num_lines, const FVector2 *c
// Try sort at longest axis, then if that fails then the other one. // Try sort at longest axis, then if that fails then the other one.
// We place the sorted lines into work_buffer and then move the result back to the lines list when done. // We place the sorted lines into work_buffer and then move the result back to the lines list when done.
int left_count, right_count; int left_count, right_count;
FVector2 axis;
for (int attempt = 0; attempt < 2; attempt++) for (int attempt = 0; attempt < 2; attempt++)
{ {
// Find the sort plane for axis // Find the sort plane for axis

View File

@ -319,7 +319,6 @@ void FMaterial::SetSpriteRect()
bool FMaterial::TrimBorders(uint16_t *rect) bool FMaterial::TrimBorders(uint16_t *rect)
{ {
PalEntry col;
int w; int w;
int h; int h;

View File

@ -46,7 +46,7 @@ class FString;
class FName class FName
{ {
public: public:
FName() = default;// : Index(0) {} FName() = default;
FName (const char *text) { Index = NameData.FindName (text, false); } FName (const char *text) { Index = NameData.FindName (text, false); }
FName (const char *text, bool noCreate) { Index = NameData.FindName (text, noCreate); } FName (const char *text, bool noCreate) { Index = NameData.FindName (text, noCreate); }
FName (const char *text, size_t textlen, bool noCreate) { Index = NameData.FindName (text, textlen, noCreate); } FName (const char *text, size_t textlen, bool noCreate) { Index = NameData.FindName (text, textlen, noCreate); }
@ -63,7 +63,7 @@ public:
FName &operator = (const char *text) { Index = NameData.FindName (text, false); return *this; } FName &operator = (const char *text) { Index = NameData.FindName (text, false); return *this; }
FName &operator = (const FString &text); FName &operator = (const FString &text);
FName &operator = (const FName &other) { Index = other.Index; return *this; } FName &operator = (const FName &other) = default;
FName &operator = (ENamedName index) { Index = index; return *this; } FName &operator = (ENamedName index) { Index = index; return *this; }
int SetName (const char *text, bool noCreate=false) { return Index = NameData.FindName (text, noCreate); } int SetName (const char *text, bool noCreate=false) { return Index = NameData.FindName (text, noCreate); }

View File

@ -2345,7 +2345,6 @@ double P_XYMovement (AActor *mo, DVector2 scroll)
{ {
static int pushtime = 0; static int pushtime = 0;
bool bForceSlide = !scroll.isZero(); bool bForceSlide = !scroll.isZero();
DAngle Angle;
DVector2 ptry; DVector2 ptry;
player_t *player; player_t *player;
DVector2 move; DVector2 move;

View File

@ -306,7 +306,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
{ {
if (sec.Lines.Size() != 3) continue; // only works with triangular sectors if (sec.Lines.Size() != 3) continue; // only works with triangular sectors
DVector3 vt1, vt2, vt3, cross; DVector3 vt1, vt2, vt3;
DVector3 vec1, vec2; DVector3 vec1, vec2;
int vi1, vi2, vi3; int vi1, vi2, vi3;

View File

@ -114,15 +114,8 @@ public:
{ {
ID = S_FindSound(name.GetChars()); ID = S_FindSound(name.GetChars());
} }
FSoundID(const FSoundID &other) FSoundID(const FSoundID &other) = default;
{ FSoundID &operator=(const FSoundID &other) = default;
ID = other.ID;
}
FSoundID &operator=(const FSoundID &other)
{
ID = other.ID;
return *this;
}
FSoundID &operator=(const char *name) FSoundID &operator=(const char *name)
{ {
ID = S_FindSound(name); ID = S_FindSound(name);
@ -168,19 +161,7 @@ class FSoundIDNoInit : public FSoundID
{ {
public: public:
FSoundIDNoInit() : FSoundID(NoInit) {} FSoundIDNoInit() : FSoundID(NoInit) {}
using FSoundID::operator=;
FSoundID &operator=(const FSoundID &other)
{
return FSoundID::operator=(other);
}
FSoundID &operator=(const char *name)
{
return FSoundID::operator=(name);
}
FSoundID &operator=(const FString &name)
{
return FSoundID::operator=(name);
}
}; };
extern FRolloffInfo S_Rolloff; extern FRolloffInfo S_Rolloff;

View File

@ -57,12 +57,6 @@ public:
class cycle_t class cycle_t
{ {
public: public:
cycle_t &operator= (const cycle_t &o)
{
Sec = o.Sec;
return *this;
}
void Reset() void Reset()
{ {
Sec = 0; Sec = 0;
@ -153,12 +147,6 @@ inline uint64_t rdtsc()
class cycle_t class cycle_t
{ {
public: public:
cycle_t &operator= (const cycle_t &o)
{
Counter = o.Counter;
return *this;
}
void Reset() void Reset()
{ {
Counter = 0; Counter = 0;

View File

@ -961,8 +961,6 @@ PalEntry FTexture::averageColor(const uint32_t *data, int size, int maxout)
PalEntry FTexture::GetSkyCapColor(bool bottom) PalEntry FTexture::GetSkyCapColor(bool bottom)
{ {
PalEntry col;
if (!bSWSkyColorDone) if (!bSWSkyColorDone)
{ {
bSWSkyColorDone = true; bSWSkyColorDone = true;

View File

@ -66,19 +66,14 @@ struct TVector2
{ {
vec_t X, Y; vec_t X, Y;
TVector2 () TVector2() = default;
{
}
TVector2 (vec_t a, vec_t b) TVector2 (vec_t a, vec_t b)
: X(a), Y(b) : X(a), Y(b)
{ {
} }
TVector2 (const TVector2 &other) TVector2(const TVector2 &other) = default;
: X(other.X), Y(other.Y)
{
}
TVector2 (const TVector3<vec_t> &other) // Copy the X and Y from the 3D vector and discard the Z TVector2 (const TVector3<vec_t> &other) // Copy the X and Y from the 3D vector and discard the Z
: X(other.X), Y(other.Y) : X(other.X), Y(other.Y)
@ -95,18 +90,7 @@ struct TVector2
return X == 0 && Y == 0; return X == 0 && Y == 0;
} }
TVector2 &operator= (const TVector2 &other) TVector2 &operator= (const TVector2 &other) = default;
{
// This might seem backwards, but this helps produce smaller code when a newly
// created vector is assigned, because the components can just be popped off
// the FPU stack in order without the need for fxch. For platforms with a
// more sensible registered-based FPU, of course, the order doesn't matter.
// (And, yes, I know fxch can improve performance in the right circumstances,
// but this isn't one of those times. Here, it's little more than a no-op that
// makes the exe 2 bytes larger whenever you assign one vector to another.)
Y = other.Y, X = other.X;
return *this;
}
// Access X and Y as an array // Access X and Y as an array
vec_t &operator[] (int index) vec_t &operator[] (int index)
@ -317,9 +301,7 @@ struct TVector3
vec_t X, Y, Z; vec_t X, Y, Z;
TVector3 () TVector3() = default;
{
}
TVector3 (vec_t a, vec_t b, vec_t c) TVector3 (vec_t a, vec_t b, vec_t c)
: X(a), Y(b), Z(c) : X(a), Y(b), Z(c)
@ -331,10 +313,7 @@ struct TVector3
{ {
} }
TVector3 (const TVector3 &other) TVector3(const TVector3 &other) = default;
: X(other.X), Y(other.Y), Z(other.Z)
{
}
TVector3 (const Vector2 &xy, vec_t z) TVector3 (const Vector2 &xy, vec_t z)
: X(xy.X), Y(xy.Y), Z(z) : X(xy.X), Y(xy.Y), Z(z)
@ -353,11 +332,7 @@ struct TVector3
return X == 0 && Y == 0 && Z == 0; return X == 0 && Y == 0 && Z == 0;
} }
TVector3 &operator= (const TVector3 &other) TVector3 &operator= (const TVector3 &other) = default;
{
Z = other.Z, Y = other.Y, X = other.X;
return *this;
}
// Access X and Y and Z as an array // Access X and Y and Z as an array
vec_t &operator[] (int index) vec_t &operator[] (int index)
@ -546,13 +521,12 @@ struct TVector3
{ {
right = { 0.f, 0.f, 1.f }; right = { 0.f, 0.f, 1.f };
} }
else if (major == 1 || (major == 2 && n[2] > 0.f))
if (major == 1 || (major == 2 && n[2] > 0.f))
{ {
right = { 1.f, 0.f, 0.f }; right = { 1.f, 0.f, 0.f };
} }
// Unconditional to ease static analysis
if (major == 2 && n[2] < 0.0f) else // major == 2 && n[2] <= 0.0f
{ {
right = { -1.f, 0.f, 0.f }; right = { -1.f, 0.f, 0.f };
} }
@ -662,9 +636,7 @@ struct TVector4
vec_t X, Y, Z, W; vec_t X, Y, Z, W;
TVector4() TVector4() = default;
{
}
TVector4(vec_t a, vec_t b, vec_t c, vec_t d) TVector4(vec_t a, vec_t b, vec_t c, vec_t d)
: X(a), Y(b), Z(c), W(d) : X(a), Y(b), Z(c), W(d)
@ -676,10 +648,7 @@ struct TVector4
{ {
} }
TVector4(const TVector4 &other) TVector4(const TVector4 &other) = default;
: X(other.X), Y(other.Y), Z(other.Z), W(other.W)
{
}
TVector4(const Vector3 &xyz, vec_t w) TVector4(const Vector3 &xyz, vec_t w)
: X(xyz.X), Y(xyz.Y), Z(xyz.Z), W(w) : X(xyz.X), Y(xyz.Y), Z(xyz.Z), W(w)
@ -696,11 +665,7 @@ struct TVector4
return X == 0 && Y == 0 && Z == 0 && W == 0; return X == 0 && Y == 0 && Z == 0 && W == 0;
} }
TVector4 &operator= (const TVector4 &other) TVector4 &operator= (const TVector4 &other) = default;
{
W = other.W, Z = other.Z, Y = other.Y, X = other.X;
return *this;
}
// Access X and Y and Z as an array // Access X and Y and Z as an array
vec_t &operator[] (int index) vec_t &operator[] (int index)
@ -939,16 +904,8 @@ struct TMatrix3x3
vec_t Cells[3][3]; vec_t Cells[3][3];
TMatrix3x3() TMatrix3x3() = default;
{ TMatrix3x3(const TMatrix3x3 &other) = default;
}
TMatrix3x3(const TMatrix3x3 &other)
{
(*this)[0] = other[0];
(*this)[1] = other[1];
(*this)[2] = other[2];
}
TMatrix3x3(const Vector3 &row1, const Vector3 &row2, const Vector3 &row3) TMatrix3x3(const Vector3 &row1, const Vector3 &row2, const Vector3 &row3)
{ {
@ -1151,32 +1108,15 @@ struct TAngle
TAngle &operator= (long other) = delete; TAngle &operator= (long other) = delete;
TAngle &operator= (unsigned long other) = delete; TAngle &operator= (unsigned long other) = delete;
TAngle () TAngle() = default;
{
}
TAngle (vec_t amt) TAngle (vec_t amt)
: Degrees(amt) : Degrees(amt)
{ {
} }
/* TAngle(const TAngle &other) = default;
TAngle (int amt) TAngle &operator= (const TAngle &other) = default;
: Degrees(vec_t(amt))
{
}
*/
TAngle (const TAngle &other)
: Degrees(other.Degrees)
{
}
TAngle &operator= (const TAngle &other)
{
Degrees = other.Degrees;
return *this;
}
TAngle &operator= (double other) TAngle &operator= (double other)
{ {
@ -1491,25 +1431,15 @@ struct TRotator
Angle Roll; // rotation about the forward axis. Angle Roll; // rotation about the forward axis.
Angle CamRoll; // Roll specific to actor cameras. Used by quakes. Angle CamRoll; // Roll specific to actor cameras. Used by quakes.
TRotator () TRotator() = default;
{
}
TRotator (const Angle &p, const Angle &y, const Angle &r) TRotator (const Angle &p, const Angle &y, const Angle &r)
: Pitch(p), Yaw(y), Roll(r) : Pitch(p), Yaw(y), Roll(r)
{ {
} }
TRotator (const TRotator &other) TRotator(const TRotator &other) = default;
: Pitch(other.Pitch), Yaw(other.Yaw), Roll(other.Roll) TRotator &operator= (const TRotator &other) = default;
{
}
TRotator &operator= (const TRotator &other)
{
Roll = other.Roll, Yaw = other.Yaw, Pitch = other.Pitch;
return *this;
}
// Access angles as an array // Access angles as an array
Angle &operator[] (int index) Angle &operator[] (int index)

View File

@ -580,7 +580,7 @@ long FString::LastIndexOfAny (const char *charset, long endIndex) const
long FString::LastIndexOf (const FString &substr) const long FString::LastIndexOf (const FString &substr) const
{ {
return LastIndexOf(substr.Chars, Len() - substr.Len(), substr.Len()); return LastIndexOf(substr.Chars, long(Len() - substr.Len()), substr.Len());
} }
long FString::LastIndexOf (const FString &substr, long endIndex) const long FString::LastIndexOf (const FString &substr, long endIndex) const
@ -590,7 +590,7 @@ long FString::LastIndexOf (const FString &substr, long endIndex) const
long FString::LastIndexOf (const char *substr) const long FString::LastIndexOf (const char *substr) const
{ {
return LastIndexOf(substr, Len() - strlen(substr), strlen(substr)); return LastIndexOf(substr, long(Len() - strlen(substr)), strlen(substr));
} }
long FString::LastIndexOf (const char *substr, long endIndex) const long FString::LastIndexOf (const char *substr, long endIndex) const
@ -602,7 +602,7 @@ long FString::LastIndexOf (const char *substr, long endIndex, size_t substrlen)
{ {
if ((size_t)endIndex + substrlen > Len()) if ((size_t)endIndex + substrlen > Len())
{ {
endIndex = Len() - substrlen; endIndex = long(Len() - substrlen);
} }
while (endIndex >= 0) while (endIndex >= 0)
{ {