From a47384c81aa3f7149e3fbe8d0034782417793fe8 Mon Sep 17 00:00:00 2001 From: Antoine Fontaine Date: Sun, 21 Mar 2021 03:51:21 +0100 Subject: [PATCH] various: add explicit default contructors --- libs/eclasslib.h | 2 ++ libs/splines/math_angles.h | 14 ++++---------- libs/splines/math_quaternion.h | 10 ++-------- libs/splines/math_vector.h | 11 ++--------- libs/string/string.h | 2 ++ radiant/brush.h | 2 ++ 6 files changed, 14 insertions(+), 27 deletions(-) diff --git a/libs/eclasslib.h b/libs/eclasslib.h index a733676a..15574450 100644 --- a/libs/eclasslib.h +++ b/libs/eclasslib.h @@ -78,8 +78,10 @@ class EntityClassAttribute CopiedString m_description; EntityClassAttribute(){ } + EntityClassAttribute(const EntityClassAttribute& attr) = default; EntityClassAttribute( const char* type, const char* name, const char* value = "", const char* description = "" ) : m_type( type ), m_name( name ), m_value( value ), m_description( description ){ } + EntityClassAttribute& operator=(const EntityClassAttribute& attr) = default; }; typedef std::pair EntityClassAttributePair; diff --git a/libs/splines/math_angles.h b/libs/splines/math_angles.h index ee1d1f82..e1916ca7 100644 --- a/libs/splines/math_angles.h +++ b/libs/splines/math_angles.h @@ -53,8 +53,8 @@ public: void set( float pitch, float yaw, float roll ); - void operator=( angles_t const &a ); - void operator=( idVec3 const &a ); + angles_t &operator=( angles_t const &a ) = default; + angles_t &operator=( idVec3 const &a ); friend angles_t operator+( const angles_t &a, const angles_t &b ); angles_t &operator+=( angles_t const &a ); @@ -68,7 +68,6 @@ public: angles_t &operator*=( float a ); friend int operator==( angles_t &a, angles_t &b ); - friend int operator!=( angles_t &a, angles_t &b ); void toVectors( idVec3 *forward, idVec3 *right = NULL, idVec3 *up = NULL ); @@ -116,16 +115,11 @@ inline void angles_t::set( float pitch, float yaw, float roll ) { this->roll = roll; } -inline void angles_t::operator=( angles_t const &a ) { - pitch = a.pitch; - yaw = a.yaw; - roll = a.roll; -} - -inline void angles_t::operator=( idVec3 const &a ) { +inline angles_t &angles_t::operator=( idVec3 const &a ) { pitch = a[ 0 ]; yaw = a[ 1 ]; roll = a[ 2 ]; + return *this; } inline angles_t operator+( const angles_t &a, const angles_t &b ) { diff --git a/libs/splines/math_quaternion.h b/libs/splines/math_quaternion.h index d428afbd..e8341c04 100644 --- a/libs/splines/math_quaternion.h +++ b/libs/splines/math_quaternion.h @@ -38,6 +38,7 @@ public: quat_t(); quat_t( float x, float y, float z, float w ); + quat_t( const quat_t & ) = default; friend void toQuat( idVec3_t &src, quat_t &dst ); friend void toQuat( angles_t &src, quat_t &dst ); @@ -50,7 +51,7 @@ public: void set( float x, float y, float z, float w ); - void operator=( quat_t a ); + quat_t &operator=( const quat_t &a ) = default; friend quat_t operator+( quat_t a, quat_t b ); quat_t &operator+=( quat_t a ); @@ -102,13 +103,6 @@ inline void quat_t::set( float x, float y, float z, float w ) { this->w = w; } -inline void quat_t::operator=( quat_t a ) { - x = a.x; - y = a.y; - z = a.z; - w = a.w; -} - inline quat_t operator+( quat_t a, quat_t b ) { return quat_t( a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w ); } diff --git a/libs/splines/math_vector.h b/libs/splines/math_vector.h index 3e6372e5..328ca3fe 100644 --- a/libs/splines/math_vector.h +++ b/libs/splines/math_vector.h @@ -135,6 +135,7 @@ public: idVec3() {dist = 0.0f; }; #endif idVec3( const float x, const float y, const float z ); + idVec3( const idVec3& ) = default; operator float *(); @@ -145,7 +146,7 @@ public: idVec3 operator-() const; - idVec3 &operator=( const idVec3 &a ); + idVec3 &operator=( const idVec3 &a ) = default; float operator*( const idVec3 &a ) const; idVec3 operator*( const float a ) const; @@ -206,14 +207,6 @@ ID_INLINE idVec3 idVec3::operator-() const { return idVec3( -x, -y, -z ); } -ID_INLINE idVec3 &idVec3::operator=( const idVec3 &a ) { - x = a.x; - y = a.y; - z = a.z; - - return *this; -} - ID_INLINE void idVec3::set( const float x, const float y, const float z ) { this->x = x; this->y = y; diff --git a/libs/string/string.h b/libs/string/string.h index 72423b57..5d63925d 100644 --- a/libs/string/string.h +++ b/libs/string/string.h @@ -328,6 +328,8 @@ public: : Buffer( range ){ } + String(const String&) = default; + String& operator=( const String& other ){ String temp( other ); temp.swap( *this ); diff --git a/radiant/brush.h b/radiant/brush.h index 9b91386c..01a61fec 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -654,6 +654,8 @@ public: return FacePlane::m_type == eBrushTypeDoom3 || FacePlane::m_type == eBrushTypeQuake4; } + FacePlane& operator=(const FacePlane&) = default; + class SavedState { public: -- 2.39.2