Skip to content

Commit

Permalink
Added C++17 [[nodiscard]] support #1217
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Feb 9, 2024
1 parent 9356f40 commit 7c724bb
Show file tree
Hide file tree
Showing 22 changed files with 482 additions and 468 deletions.
8 changes: 4 additions & 4 deletions glm/detail/func_common.inl
Original file line number Diff line number Diff line change
Expand Up @@ -542,25 +542,25 @@ namespace detail
}

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> splatX(vec<L, T, Q> const& a)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> splatX(vec<L, T, Q> const& a)
{
return detail::convert_splat<L, T, Q, detail::is_aligned<Q>::value>::template call<0>(a);
}

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> splatY(vec<L, T, Q> const& a)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> splatY(vec<L, T, Q> const& a)
{
return detail::convert_splat<L, T, Q, detail::is_aligned<Q>::value>::template call<1>(a);
}

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> splatZ(vec<L, T, Q> const& a)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> splatZ(vec<L, T, Q> const& a)
{
return detail::convert_splat<L, T, Q, detail::is_aligned<Q>::value>::template call<2>(a);
}

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> splatW(vec<L, T, Q> const& a)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> splatW(vec<L, T, Q> const& a)
{
return detail::convert_splat<L, T, Q, detail::is_aligned<Q>::value>::template call<3>(a);
}
Expand Down
11 changes: 10 additions & 1 deletion glm/detail/setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@
# define GLM_IF_CONSTEXPR if
#endif

// [nodiscard]
#if GLM_LANG & GLM_LANG_CXX17_FLAG
# define GLM_NODISCARD [[nodiscard]]
#else
# define GLM_NODISCARD
#endif

//
#if GLM_LANG & GLM_LANG_CXX11_FLAG
# define GLM_HAS_ASSIGNABLE 1
Expand Down Expand Up @@ -486,7 +493,9 @@
# define GLM_NEVER_INLINE
#endif//defined(GLM_FORCE_INLINE)

#define GLM_FUNC_DECL GLM_CUDA_FUNC_DECL
#define GLM_CTOR_DECL GLM_CUDA_FUNC_DECL GLM_CONSTEXPR
#define GLM_FUNC_DISCARD_DECL GLM_CUDA_FUNC_DECL
#define GLM_FUNC_DECL GLM_NODISCARD GLM_CUDA_FUNC_DECL
#define GLM_FUNC_QUALIFIER GLM_CUDA_FUNC_DEF GLM_INLINE

// Do not use CUDA function qualifiers on CUDA compiler when functions are made default
Expand Down
52 changes: 26 additions & 26 deletions glm/detail/type_mat2x2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,67 +34,67 @@ namespace glm

GLM_DEFAULTED_DEFAULT_CTOR_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR;
template<qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<2, 2, T, P> const& m);
GLM_CTOR_DECL mat(mat<2, 2, T, P> const& m);

GLM_FUNC_DECL explicit GLM_CONSTEXPR mat(T scalar);
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL GLM_EXPLICIT mat(T scalar);
GLM_CTOR_DECL mat(
T const& x1, T const& y1,
T const& x2, T const& y2);
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
col_type const& v1,
col_type const& v2);

// -- Conversions --

template<typename U, typename V, typename M, typename N>
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
U const& x1, V const& y1,
M const& x2, N const& y2);

template<typename U, typename V>
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
vec<2, U, Q> const& v1,
vec<2, V, Q> const& v2);

// -- Matrix conversions --

template<typename U, qualifier P>
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 2, U, P> const& m);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 2, U, P> const& m);

GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 3, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 4, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 3, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 2, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 4, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 2, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 4, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 3, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 3, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 4, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 3, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 2, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 4, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 2, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 4, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 3, T, Q> const& x);

// -- Unary arithmetic operators --

template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator=(mat<2, 2, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator=(mat<2, 2, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator+=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator+=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator+=(mat<2, 2, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator+=(mat<2, 2, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-=(mat<2, 2, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-=(mat<2, 2, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator*=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator*=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator*=(mat<2, 2, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator*=(mat<2, 2, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator/=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator/=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator/=(mat<2, 2, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator/=(mat<2, 2, U, Q> const& m);

// -- Increment and decrement operators --

GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator++ ();
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-- ();
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator++ ();
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-- ();
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator++(int);
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator--(int);
};
Expand Down
48 changes: 24 additions & 24 deletions glm/detail/type_mat2x3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,63 +35,63 @@ namespace glm

GLM_DEFAULTED_DEFAULT_CTOR_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR;
template<qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<2, 3, T, P> const& m);
GLM_CTOR_DECL mat(mat<2, 3, T, P> const& m);

GLM_FUNC_DECL explicit GLM_CONSTEXPR mat(T scalar);
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL GLM_EXPLICIT mat(T scalar);
GLM_CTOR_DECL mat(
T x0, T y0, T z0,
T x1, T y1, T z1);
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
col_type const& v0,
col_type const& v1);

// -- Conversions --

template<typename X1, typename Y1, typename Z1, typename X2, typename Y2, typename Z2>
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
X1 x1, Y1 y1, Z1 z1,
X2 x2, Y2 y2, Z2 z2);

template<typename U, typename V>
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
vec<3, U, Q> const& v1,
vec<3, V, Q> const& v2);

// -- Matrix conversions --

template<typename U, qualifier P>
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 3, U, P> const& m);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 3, U, P> const& m);

GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 2, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 3, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 4, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 4, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 2, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 4, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 2, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 3, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 2, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 3, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 4, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 4, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 2, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 4, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 2, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 3, T, Q> const& x);

// -- Unary arithmetic operators --

template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator=(mat<2, 3, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator=(mat<2, 3, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator+=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator+=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator+=(mat<2, 3, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator+=(mat<2, 3, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-=(mat<2, 3, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-=(mat<2, 3, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator*=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator*=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator/=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator/=(U s);

// -- Increment and decrement operators --

GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator++ ();
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-- ();
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator++ ();
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-- ();
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator++(int);
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator--(int);
};
Expand Down
48 changes: 24 additions & 24 deletions glm/detail/type_mat2x4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ namespace glm

GLM_DEFAULTED_DEFAULT_CTOR_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR;
template<qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<2, 4, T, P> const& m);
GLM_CTOR_DECL mat(mat<2, 4, T, P> const& m);

GLM_FUNC_DECL explicit GLM_CONSTEXPR mat(T scalar);
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL GLM_EXPLICIT mat(T scalar);
GLM_CTOR_DECL mat(
T x0, T y0, T z0, T w0,
T x1, T y1, T z1, T w1);
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
col_type const& v0,
col_type const& v1);

Expand All @@ -50,50 +50,50 @@ namespace glm
template<
typename X1, typename Y1, typename Z1, typename W1,
typename X2, typename Y2, typename Z2, typename W2>
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
X1 x1, Y1 y1, Z1 z1, W1 w1,
X2 x2, Y2 y2, Z2 z2, W2 w2);

template<typename U, typename V>
GLM_FUNC_DECL GLM_CONSTEXPR mat(
GLM_CTOR_DECL mat(
vec<4, U, Q> const& v1,
vec<4, V, Q> const& v2);

// -- Matrix conversions --

template<typename U, qualifier P>
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 4, U, P> const& m);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 4, U, P> const& m);

GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 2, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 3, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 4, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 3, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 2, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 4, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 2, T, Q> const& x);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 3, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 2, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 3, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 4, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<2, 3, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 2, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 4, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 2, T, Q> const& x);
GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 3, T, Q> const& x);

// -- Unary arithmetic operators --

template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator=(mat<2, 4, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator=(mat<2, 4, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator+=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator+=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator+=(mat<2, 4, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator+=(mat<2, 4, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-=(mat<2, 4, U, Q> const& m);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-=(mat<2, 4, U, Q> const& m);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator*=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator*=(U s);
template<typename U>
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator/=(U s);
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator/=(U s);

// -- Increment and decrement operators --

GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator++ ();
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-- ();
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator++ ();
GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-- ();
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator++(int);
GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator--(int);
};
Expand Down
Loading

0 comments on commit 7c724bb

Please sign in to comment.