Experiment for issue #532

This commit is contained in:
Christophe Riccio 2016-11-12 20:47:53 +01:00
parent 83d14ee411
commit 952ab91dd7
4 changed files with 581 additions and 34 deletions

View File

@ -381,6 +381,17 @@
(GLM_COMPILER & GLM_COMPILER_CUDA)))
#endif
// N3638 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3638.html
#if GLM_COMPILER & GLM_COMPILER_CLANG
# define GLM_HAS_DECLTYPE __has_feature(cxx_decltype)
#elif GLM_LANG & GLM_LANG_CXX14_FLAG
# define GLM_HAS_DECLTYPE 1
#else
# define GLM_HAS_DECLTYPE ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14))))
#endif
// N2118
#if GLM_COMPILER & GLM_COMPILER_CLANG
# define GLM_HAS_RVALUE_REFERENCES __has_feature(cxx_rvalue_references)

View File

@ -278,6 +278,161 @@ namespace glm
// -- Binary operators --
#if GLM_HAS_DECLTYPE
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator+(tvec4<T, P> const& v, U scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator+(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator+(tvec4<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator+(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator+(tvec1<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator+(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator-(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator-(tvec4<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator-(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator-(tvec1<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator-(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator*(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator*(tvec4<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator*(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator*(tvec1<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator*(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator/(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator/(tvec4<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator/(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator/(tvec1<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator/(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator%(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator%(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator%(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator%(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator%(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator&(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator&(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator&(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator&(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator&(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator|(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator|(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator|(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator|(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator|(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator^(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator^(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator^(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator^(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator^(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator<<(tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator<<(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator<<(T scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator<<(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator<<(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator >> (tvec4<T, P> const & v, T scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator >> (tvec4<T, P> const & v, tvec1<U, P> const & scalar);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator >> (T scalar, tvec4<U, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator >> (tvec1<T, P> const & scalar, tvec4<U, P> const & v);
template <typename T, typename U, precision P>
GLM_FUNC_DECL auto operator >> (tvec4<T, P> const & v1, tvec4<U, P> const & v2);
#else//GLM_HAS_DECLTYPE
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v, T scalar);
@ -427,8 +582,9 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
#endif//GLM_HAS_DECLTYPE
template <typename T, precision P>
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator~(tvec4<T, P> const & v);
// -- Boolean operators --

View File

@ -365,84 +365,84 @@ namespace detail
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator+=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator+=(U scalar)
{
return (*this = detail::compute_vec4_add<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator+=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator+=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_add<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v.x)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator+=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator+=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_add<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator-=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator-=(U scalar)
{
return (*this = detail::compute_vec4_sub<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator-=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator-=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_sub<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v.x)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator-=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator-=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_sub<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator*=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator*=(U scalar)
{
return (*this = detail::compute_vec4_mul<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator*=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator*=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_mul<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v.x)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator*=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator*=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_mul<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator/=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator/=(U scalar)
{
return (*this = detail::compute_vec4_div<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator/=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator/=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_div<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v.x)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator/=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator/=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_div<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
@ -450,7 +450,7 @@ namespace detail
// -- Increment and decrement operators --
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator++()
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator++()
{
++this->x;
++this->y;
@ -460,7 +460,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator--()
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator--()
{
--this->x;
--this->y;
@ -489,126 +489,126 @@ namespace detail
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator%=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator%=(U scalar)
{
return (*this = detail::compute_vec4_mod<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator%=(tvec1<U, P> const& v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator%=(tvec1<U, P> const& v)
{
return (*this = detail::compute_vec4_mod<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator%=(tvec4<U, P> const& v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator%=(tvec4<U, P> const& v)
{
return (*this = detail::compute_vec4_mod<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator&=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator&=(U scalar)
{
return (*this = detail::compute_vec4_and<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator&=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator&=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_and<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator&=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator&=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_and<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator|=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator|=(U scalar)
{
return (*this = detail::compute_vec4_or<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator|=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator|=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_or<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator|=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator|=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_or<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator^=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator^=(U scalar)
{
return (*this = detail::compute_vec4_xor<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator^=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator^=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_xor<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator^=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator^=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_xor<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator<<=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator<<=(U scalar)
{
return (*this = detail::compute_vec4_shift_left<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator<<=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator<<=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_shift_left<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator<<=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator<<=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_shift_left<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator>>=(U scalar)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator>>=(U scalar)
{
return (*this = detail::compute_vec4_shift_right<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator>>=(tvec1<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator>>=(tvec1<U, P> const & v)
{
return (*this = detail::compute_vec4_shift_right<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator>>=(tvec4<U, P> const & v)
GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator>>=(tvec4<U, P> const & v)
{
return (*this = detail::compute_vec4_shift_right<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v)));
}
@ -629,8 +629,363 @@ namespace detail
// -- Binary arithmetic operators --
#if GLM_HAS_DECLTYPE
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator+(tvec4<T, P> const& v, U s)
{
typedef tvec4<decltype(v.x+s), P> xvec4;
return detail::compute_vec4_add<decltype(v.x+s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x+s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator+(tvec4<T, P> const& v1, tvec1<U, P> const& v2)
{
typedef tvec4<decltype(v1.x+v2.x), P> xvec4;
return detail::compute_vec4_add<decltype(v1.x+v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator+(T s, tvec4<U, P> const& v)
{
typedef tvec4<decltype(s+v.x), P> xvec4;
return detail::compute_vec4_add<decltype(s+v.x), P, detail::is_aligned<P>::value>::call(xvec4(static_cast<decltype(s+v.x)>(s)), xvec4(v));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator+(tvec1<T, P> const& v1, tvec4<U, P> const& v2)
{
typedef tvec4<decltype(v1.x+v2.x), P> xvec4;
return detail::compute_vec4_add<decltype(v1.x+v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator+(tvec4<T, P> const& v1, tvec4<U, P> const& v2)
{
typedef tvec4<decltype(v1.x+v2.x), P> xvec4;
return detail::compute_vec4_add<decltype(v1.x+v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator-(tvec4<T, P> const& v, U s)
{
typedef tvec4<decltype(v.x - s), P> xvec4;
return detail::compute_vec4_sub<decltype(v.x - s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x - s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator-(tvec4<T, P> const& v1, tvec1<U, P> const& v2)
{
typedef tvec4<decltype(v1.x - v2.x), P> xvec4;
return detail::compute_vec4_sub<decltype(v1.x - v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator-(T s, tvec4<U, P> const& v)
{
typedef tvec4<decltype(s - v.x), P> xvec4;
return detail::compute_vec4_sub<decltype(s - v.x), P, detail::is_aligned<P>::value>::call(xvec4(static_cast<decltype(s - v.x)>(s)), xvec4(v));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator-(tvec1<T, P> const& v1, tvec4<U, P> const& v2)
{
typedef tvec4<decltype(v1.x - v2.x), P> xvec4;
return detail::compute_vec4_sub<decltype(v1.x - v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator-(tvec4<T, P> const& v1, tvec4<U, P> const& v2)
{
typedef tvec4<decltype(v1.x - v2.x), P> xvec4;
return detail::compute_vec4_sub<decltype(v1.x - v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator*(tvec4<T, P> const& v, U s)
{
typedef tvec4<decltype(v.x * s), P> xvec4;
return detail::compute_vec4_mul<decltype(v.x * s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x * s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator*(tvec4<T, P> const& v1, tvec1<U, P> const& v2)
{
typedef tvec4<decltype(v1.x * v2.x), P> xvec4;
return detail::compute_vec4_mul<decltype(v1.x * v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator*(T s, tvec4<U, P> const& v)
{
typedef tvec4<decltype(v.x * s), P> xvec4;
return detail::compute_vec4_mul<decltype(v.x * s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x * s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator*(tvec1<T, P> const& v1, tvec4<U, P> const& v2)
{
typedef tvec4<decltype(v1.x * v2.x), P> xvec4;
return detail::compute_vec4_mul<decltype(v1.x * v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator*(tvec4<T, P> const& v1, tvec4<U, P> const& v2)
{
typedef tvec4<decltype(v1.x * v2.x), P> xvec4;
return detail::compute_vec4_mul<decltype(v1.x * v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator/(tvec4<T, P> const& v, U s)
{
typedef tvec4<decltype(v.x / s), P> xvec4;
return detail::compute_vec4_div<decltype(v.x / s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x / s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator/(tvec4<T, P> const& v1, tvec1<U, P> const& v2)
{
typedef tvec4<decltype(v1.x / v2.x), P> xvec4;
return detail::compute_vec4_div<decltype(v1.x / v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator/(T s, tvec4<U, P> const& v)
{
typedef tvec4<decltype(s / v.x), P> xvec4;
return detail::compute_vec4_div<decltype(s / v.x), P, detail::is_aligned<P>::value>::call(xvec4(static_cast<decltype(s / v.x)>(s)), xvec4(v));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator/(tvec1<T, P> const& v1, tvec4<U, P> const& v2)
{
typedef tvec4<decltype(v1.x / v2.x), P> xvec4;
return detail::compute_vec4_div<decltype(v1.x / v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator/(tvec4<T, P> const& v1, tvec4<U, P> const& v2)
{
typedef tvec4<decltype(v1.x / v2.x), P> xvec4;
return detail::compute_vec4_div<decltype(v1.x / v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
// -- Binary bit operators --
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator%(tvec4<T, P> const& v, T s)
{
typedef tvec4<decltype(v.x % s), P> xvec4;
return detail::compute_vec4_mod<decltype(v.x % s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x % s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator%(tvec4<T, P> const& v1, tvec1<T, P> const& v2)
{
typedef tvec4<decltype(v1.x % v2.x), P> xvec4;
return detail::compute_vec4_mod<decltype(v1.x % v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(static_cast<decltype(v1.x % v2.x)>(v2)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator%(T s, tvec4<T, P> const& v)
{
typedef tvec4<decltype(s % v.x), P> xvec4;
return detail::compute_vec4_mod<decltype(s % v.x), P, detail::is_aligned<P>::value>::call(xvec4(static_cast<decltype(s % v.x)>(s)), xvec4(v));
return tvec4<T, P>(scalar) %= v;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator%(tvec1<T, P> const& s, tvec4<T, P> const& v)
{
typedef tvec4<decltype(v1.x % v2.x), P> xvec4;
return tvec4<T, P>(scalar.x) %= v;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator%(tvec4<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x % v2.x), P> xvec4;
return detail::compute_vec4_mod<decltype(v1.x % v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(static_cast<decltype(v1.x % v2.x)>(v2)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator&(tvec4<T, P> const& v, T s)
{
typedef tvec4<decltype(v & s), P> xvec4;
return detail::compute_vec4_and<decltype(v.x & s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x & s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator&(tvec4<T, P> const& v1, tvec1<T, P> const& v2)
{
typedef tvec4<decltype(v1.x & v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x & v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator&(T s, tvec4<T, P> const& v)
{
typedef tvec4<decltype(v & s), P> xvec4;
return detail::compute_vec4_and<decltype(v.x & s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x & s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator&(tvec1<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x & v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x & v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator&(tvec4<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x & v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x & v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator|(tvec4<T, P> const& v, T s)
{
typedef tvec4<decltype(v | s), P> xvec4;
return detail::compute_vec4_and<decltype(v.x | s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x | s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator|(tvec4<T, P> const& v1, tvec1<T, P> const& v2)
{
typedef tvec4<decltype(v1.x | v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x | v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator|(T s, tvec4<T, P> const& v)
{
typedef tvec4<decltype(s | v), P> xvec4;
return detail::compute_vec4_and<decltype(v.x | s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x | s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator|(tvec1<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x | v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x | v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator|(tvec4<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x | v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x | v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator^(tvec4<T, P> const& v, T s)
{
typedef tvec4<decltype(v ^ s), P> xvec4;
return detail::compute_vec4_and<decltype(v.x ^ s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x ^ s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator^(tvec4<T, P> const& v1, tvec1<T, P> const& v2)
{
typedef tvec4<decltype(v1.x ^ v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x ^ v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator^(T s, tvec4<T, P> const& v)
{
typedef tvec4<decltype(s ^ v), P> xvec4;
return detail::compute_vec4_and<decltype(v.x ^ s), P, detail::is_aligned<P>::value>::call(xvec4(v), xvec4(static_cast<decltype(v.x ^ s)>(s)));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator^(tvec1<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x ^ v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x ^ v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator^(tvec4<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x ^ v2.x), P> xvec4;
return detail::compute_vec4_and<decltype(v1.x ^ v2.x), P, detail::is_aligned<P>::value>::call(xvec4(v1), xvec4(v2));
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator<<(tvec4<T, P> const& v, T s)
{
typedef tvec4<decltype(v << s), P> xvec4;
return tvec4<T, P>(v) <<= s;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator<<(tvec4<T, P> const& v1, tvec1<T, P> const& v2)
{
typedef tvec4<decltype(v1.x << v2.x), P> xvec4;
return tvec4<T, P>(v1) <<= v2.x;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator<<(T s, tvec4<T, P> const& v)
{
typedef tvec4<decltype(v >> s), P> xvec4;
return tvec4<T, P>(s) <<= v;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator<<(tvec1<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x << v2.x), P> xvec4;
return tvec4<T, P>(v1.x) <<= v2;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator<<(tvec4<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x << v2.x), P> xvec4;
return tvec4<T, P>(v1) <<= v2;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator >> (tvec4<T, P> const& v, T s)
{
typedef tvec4<decltype(v >> s), P> xvec4;
return tvec4<T, P>(v) >>= s;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator >> (tvec4<T, P> const& v1, tvec1<T, P> const& v2)
{
typedef tvec4<decltype(v1.x >> v2.x), P> xvec4;
return tvec4<T, P>(v1) >>= v2.x;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator >> (T s, tvec4<T, P> const& v)
{
typedef tvec4<decltype(s >> v), P> xvec4;
return tvec4<T, P>(s) >>= v;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator >> (tvec1<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x >> v2.x), P> xvec4;
return tvec4<T, P>(v1.x) >>= v2;
}
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER auto operator >> (tvec4<T, P> const& v1, tvec4<T, P> const& v2)
{
typedef tvec4<decltype(v1.x >> v2.x), P> xvec4;
return tvec4<T, P>(v1) >>= v2;
}
#else//GLM_HAS_DECLTYPE
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v, T scalar)
GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const& v, T scalar)
{
return tvec4<T, P>(v) += scalar;
}
@ -930,6 +1285,7 @@ namespace detail
{
return tvec4<T, P>(v1) >>= v2;
}
#endif//GLM_HAS_DECLTYPE
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator~(tvec4<T, P> const & v)

View File

@ -207,6 +207,12 @@ int test_vec4_operators()
A += 1.0f;
Error += A == glm::vec4(6, 8, 10, 12) ? 0 : 1;
# if GLM_HAS_DECLTYPE
glm::vec4 const O(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 const C = O + 1.0;
Error += C == glm::vec4(2, 3, 4, 5) ? 0 : 1;
# endif
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
@ -217,6 +223,12 @@ int test_vec4_operators()
B -= 1.0f;
Error += B == glm::vec4(2, 2, 2, 2) ? 0 : 1;
# if GLM_HAS_DECLTYPE
glm::vec4 const O(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 const C = O - 1.0;
Error += C == glm::vec4(0, 1, 2, 3) ? 0 : 1;
# endif
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
@ -227,6 +239,12 @@ int test_vec4_operators()
A *= 2.0f;
Error += A == glm::vec4(8, 20, 36, 56) ? 0 : 1;
# if GLM_HAS_DECLTYPE
glm::vec4 const O(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 const C = O * 1;
Error += C == O ? 0 : 1;
# endif
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
@ -237,6 +255,12 @@ int test_vec4_operators()
B /= 2.0f;
Error += B == glm::vec4(2, 1.25, 1, 7.0f / 4.0f / 2.0f) ? 0 : 1;
# if GLM_HAS_DECLTYPE
glm::vec4 const O(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 const C = O / 1;
Error += C == O ? 0 : 1;
# endif
}
{
glm::vec4 B(2.0f);