Added support of defaulted functions to *vec* types #366

This commit is contained in:
Christophe Riccio
2015-07-25 01:24:03 +02:00
parent 063c5c7367
commit f7751bfb06
14 changed files with 229 additions and 131 deletions

View File

@@ -619,7 +619,8 @@
#else
# define GLM_HAS_DEFAULTED_FUNCTIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \
((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12)))
#endif
// N2118
@@ -923,6 +924,12 @@
# define GLM_RESTRICT_VAR
#endif//GLM_COMPILER
#if GLM_HAS_DEFAULTED_FUNCTIONS
# define GLM_DEFAULT = default
#else
# define GLM_DEFAULT
#endif
#if GLM_HAS_CONSTEXPR
# define GLM_CONSTEXPR constexpr
# define GLM_RELAXED_CONSTEXPR constexpr

View File

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

View File

@@ -35,17 +35,19 @@ namespace glm
//////////////////////////////////////
// Implicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0)
# endif
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0)
# endif
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(tvec1<T, P> const & v)
: x(v.x)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(tvec1<T, P> const & v)
: x(v.x)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -140,12 +142,14 @@ namespace glm
//////////////////////////////////////
// Unary arithmetic operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator=(tvec1<T, P> const & v)
{
this->x = v.x;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator=(tvec1<T, P> const & v)
{
this->x = v.x;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>

View File

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

View File

@@ -28,51 +28,22 @@
namespace glm
{
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec2<T, P>::size() const
{
return 2;
}
#else
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec2<T, P>::length() const
{
return 2;
}
#endif
//////////////////////////////////////
// Accesses
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](length_t i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](length_t i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
//////////////////////////////////////
// Implicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0)
# endif
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0)
# endif
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2(tvec2<T, P> const & v)
: x(v.x), y(v.y)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2(tvec2<T, P> const & v)
: x(v.x), y(v.y)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -138,16 +109,63 @@ namespace glm
, y(static_cast<T>(v.y))
{}
//////////////////////////////////////
// Component accesses
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2<T, P>::size_type tvec2<T, P>::size() const
{
return 2;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](typename tvec2<T, P>::size_type i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](typename tvec2<T, P>::size_type i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# else
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2<T, P>::length_type tvec2<T, P>::length() const
{
return 2;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](typename tvec2<T, P>::length_type i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](typename tvec2<T, P>::length_type i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Unary arithmetic operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator=(tvec2<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator=(tvec2<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>

View File

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

View File

@@ -35,17 +35,19 @@ namespace glm
//////////////////////////////////////
// Implicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0)
# endif
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0)
# endif
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(tvec3<T, P> const & v)
: x(v.x), y(v.y), z(v.z)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(tvec3<T, P> const & v)
: x(v.x), y(v.y), z(v.z)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -188,14 +190,16 @@ namespace glm
//////////////////////////////////////
// Unary arithmetic operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>& tvec3<T, P>::operator=(tvec3<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>& tvec3<T, P>::operator=(tvec3<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>

View File

@@ -171,8 +171,8 @@ namespace detail
//////////////////////////////////////
// Implicit basic constructors
GLM_FUNC_DECL tvec4();
GLM_FUNC_DECL tvec4(tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4() GLM_DEFAULT;
GLM_FUNC_DECL tvec4(tvec4<T, P> const & v) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL tvec4(tvec4<T, Q> const & v);
@@ -182,7 +182,6 @@ namespace detail
GLM_FUNC_DECL explicit tvec4(ctor);
GLM_FUNC_DECL explicit tvec4(T s);
GLM_FUNC_DECL tvec4(T a, T b, T c, T d);
GLM_FUNC_DECL ~tvec4(){}
//////////////////////////////////////
// Conversion scalar constructors
@@ -284,7 +283,7 @@ namespace detail
//////////////////////////////////////
// Unary arithmetic operators
GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<T, P> const & v);
GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<T, P> const & v) GLM_DEFAULT;
template <typename U>
GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<U, P> const & v);

View File

@@ -35,17 +35,19 @@ namespace glm
//////////////////////////////////////
// Implicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(0)
# endif
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(0)
# endif
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(tvec4<T, P> const & v)
: x(v.x), y(v.y), z(v.z), w(v.w)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(tvec4<T, P> const & v)
: x(v.x), y(v.y), z(v.z), w(v.w)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
@@ -250,15 +252,17 @@ namespace glm
//////////////////////////////////////
// Unary arithmetic operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator=(tvec4<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
this->w = v.w;
return *this;
}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator=(tvec4<T, P> const & v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
this->w = v.w;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <typename U>

View File

@@ -31,24 +31,22 @@
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
namespace detail
{
}//namespace detail
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float s) :