Removed use of =default for vector types

Defaulting the copy constructor and copy assignment operators causes compiler errors when the type T is not trivially copyable. In that case, explicitly defined copy ctor and assignment are required. This PR removes the #ifdefs around the existing operators, so they're always used.
This commit is contained in:
Patrik Huber 2016-08-18 00:01:41 +01:00
parent c947b3338b
commit 56917bf17c
8 changed files with 54 additions and 70 deletions

View File

@ -83,7 +83,7 @@ namespace glm
// -- Implicit basic constructors -- // -- Implicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR tvec1() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR tvec1() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL GLM_CONSTEXPR tvec1(tvec1<T, P> const & v) GLM_DEFAULT; GLM_FUNC_DECL GLM_CONSTEXPR tvec1(tvec1<T, P> const & v);
template <precision Q> template <precision Q>
GLM_FUNC_DECL GLM_CONSTEXPR tvec1(tvec1<T, Q> const & v); GLM_FUNC_DECL GLM_CONSTEXPR tvec1(tvec1<T, Q> const & v);
@ -120,7 +120,7 @@ namespace glm
*/ */
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --
GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<T, P> const & v) GLM_DEFAULT; GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<T, P> const & v);
template <typename U> template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<U, P> const & v); GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<U, P> const & v);

View File

@ -14,12 +14,10 @@ namespace glm
{} {}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS # endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# if !GLM_HAS_DEFAULTED_FUNCTIONS template <typename T, precision P>
template <typename T, precision P> GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec1<T, P>::tvec1(tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec1<T, P>::tvec1(tvec1<T, P> const & v) : x(v.x)
: x(v.x) {}
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P> template <typename T, precision P>
template <precision Q> template <precision Q>
@ -88,14 +86,12 @@ namespace glm
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --
# if !GLM_HAS_DEFAULTED_FUNCTIONS template <typename T, precision P>
template <typename T, precision P> GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator=(tvec1<T, P> const & v)
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator=(tvec1<T, P> const & v) {
{ this->x = v.x;
this->x = v.x; return *this;
return *this; }
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>

View File

@ -84,7 +84,7 @@ namespace glm
// -- Implicit basic constructors -- // -- Implicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR tvec2() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR tvec2() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL GLM_CONSTEXPR tvec2(tvec2<T, P> const& v) GLM_DEFAULT; GLM_FUNC_DECL GLM_CONSTEXPR tvec2(tvec2<T, P> const& v);
template <precision Q> template <precision Q>
GLM_FUNC_DECL GLM_CONSTEXPR tvec2(tvec2<T, Q> const& v); GLM_FUNC_DECL GLM_CONSTEXPR tvec2(tvec2<T, Q> const& v);
@ -126,7 +126,7 @@ namespace glm
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --
GLM_FUNC_DECL tvec2<T, P>& operator=(tvec2<T, P> const & v) GLM_DEFAULT; GLM_FUNC_DECL tvec2<T, P>& operator=(tvec2<T, P> const & v);
template <typename U> template <typename U>
GLM_FUNC_DECL tvec2<T, P>& operator=(tvec2<U, P> const & v); GLM_FUNC_DECL tvec2<T, P>& operator=(tvec2<U, P> const & v);

View File

@ -27,12 +27,10 @@ namespace glm
{} {}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS # endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# if !GLM_HAS_DEFAULTED_FUNCTIONS template <typename T, precision P>
template <typename T, precision P> GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec2<T, P>::tvec2(tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec2<T, P>::tvec2(tvec2<T, P> const & v) : x(v.x), y(v.y)
: x(v.x), y(v.y) {}
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P> template <typename T, precision P>
template <precision Q> template <precision Q>
@ -119,15 +117,13 @@ namespace glm
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --
# if !GLM_HAS_DEFAULTED_FUNCTIONS template <typename T, precision P>
template <typename T, precision P> GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator=(tvec2<T, P> const & v)
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator=(tvec2<T, P> const & v) {
{ this->x = v.x;
this->x = v.x; this->y = v.y;
this->y = v.y; return *this;
return *this; }
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>

View File

@ -84,7 +84,7 @@ namespace glm
// -- Implicit basic constructors -- // -- Implicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR tvec3() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR tvec3() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec3<T, P> const & v) GLM_DEFAULT; GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec3<T, P> const & v);
template <precision Q> template <precision Q>
GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec3<T, Q> const & v); GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec3<T, Q> const & v);
@ -147,7 +147,7 @@ namespace glm
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --
GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<T, P> const & v) GLM_DEFAULT; GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<T, P> const & v);
template <typename U> template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<U, P> const & v); GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<U, P> const & v);

View File

@ -40,12 +40,10 @@ namespace glm
{} {}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS # endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# if !GLM_HAS_DEFAULTED_FUNCTIONS template <typename T, precision P>
template <typename T, precision P> GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec3<T, P>::tvec3(tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec3<T, P>::tvec3(tvec3<T, P> const & v) : x(v.x), y(v.y), z(v.z)
: x(v.x), y(v.y), z(v.z) {}
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P> template <typename T, precision P>
template <precision Q> template <precision Q>
@ -161,16 +159,14 @@ namespace glm
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --
# if !GLM_HAS_DEFAULTED_FUNCTIONS template <typename T, precision P>
template <typename T, precision P> GLM_FUNC_QUALIFIER tvec3<T, P>& tvec3<T, P>::operator=(tvec3<T, P> const & v)
GLM_FUNC_QUALIFIER tvec3<T, P>& tvec3<T, P>::operator=(tvec3<T, P> const & v) {
{ this->x = v.x;
this->x = v.x; this->y = v.y;
this->y = v.y; this->z = v.z;
this->z = v.z; return *this;
return *this; }
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>

View File

@ -87,7 +87,7 @@ namespace glm
// -- Implicit basic constructors -- // -- Implicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR tvec4() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR tvec4() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec4<T, P> const& v) GLM_DEFAULT; GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec4<T, P> const& v);
template <precision Q> template <precision Q>
GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec4<T, Q> const& v); GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec4<T, Q> const& v);
@ -192,7 +192,7 @@ namespace glm
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --
GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<T, P> const & v) GLM_DEFAULT; GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<T, P> const & v);
template <typename U> template <typename U>
GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<U, P> const & v); GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<U, P> const & v);

View File

@ -163,12 +163,10 @@ namespace detail
{} {}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS # endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# if !GLM_HAS_DEFAULTED_FUNCTIONS template <typename T, precision P>
template <typename T, precision P> GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec4<T, P>::tvec4(tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec4<T, P>::tvec4(tvec4<T, P> const & v) : x(v.x), y(v.y), z(v.z), w(v.w)
: x(v.x), y(v.y), z(v.z), w(v.w) {}
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P> template <typename T, precision P>
template <precision Q> template <precision Q>
@ -346,17 +344,15 @@ namespace detail
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --
# if !GLM_HAS_DEFAULTED_FUNCTIONS template <typename T, precision P>
template <typename T, precision P> GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator=(tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator=(tvec4<T, P> const & v) {
{ this->x = v.x;
this->x = v.x; this->y = v.y;
this->y = v.y; this->z = v.z;
this->z = v.z; this->w = v.w;
this->w = v.w; return *this;
return *this; }
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>