Commit 05492d65 authored by Philip Trettner's avatar Philip Trettner
Browse files

replaced TG_NODISCARD with [[nodiscard]]

parent 50aef922
...@@ -19,33 +19,33 @@ namespace tg ...@@ -19,33 +19,33 @@ namespace tg
// ================================================================== // ==================================================================
// Classification // Classification
TG_NODISCARD inline bool is_nan(f32 x) { return std::isnan(x); } [[nodiscard]] inline bool is_nan(f32 x) { return std::isnan(x); }
TG_NODISCARD inline bool is_nan(f64 x) { return std::isnan(x); } [[nodiscard]] inline bool is_nan(f64 x) { return std::isnan(x); }
TG_NODISCARD inline bool is_zero(i8 x) { return x == 0; } [[nodiscard]] inline bool is_zero(i8 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(i16 x) { return x == 0; } [[nodiscard]] inline bool is_zero(i16 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(i32 x) { return x == 0; } [[nodiscard]] inline bool is_zero(i32 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(i64 x) { return x == 0; } [[nodiscard]] inline bool is_zero(i64 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(u8 x) { return x == 0; } [[nodiscard]] inline bool is_zero(u8 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(u16 x) { return x == 0; } [[nodiscard]] inline bool is_zero(u16 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(u32 x) { return x == 0; } [[nodiscard]] inline bool is_zero(u32 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(u64 x) { return x == 0; } [[nodiscard]] inline bool is_zero(u64 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(f32 x) { return x == 0; } [[nodiscard]] inline bool is_zero(f32 x) { return x == 0; }
TG_NODISCARD inline bool is_zero(f64 x) { return x == 0; } [[nodiscard]] inline bool is_zero(f64 x) { return x == 0; }
TG_NODISCARD inline bool is_inf(f32 x) { return std::isinf(x); } [[nodiscard]] inline bool is_inf(f32 x) { return std::isinf(x); }
TG_NODISCARD inline bool is_inf(f64 x) { return std::isinf(x); } [[nodiscard]] inline bool is_inf(f64 x) { return std::isinf(x); }
TG_NODISCARD inline bool is_finite(f32 x) { return std::isfinite(x); } [[nodiscard]] inline bool is_finite(f32 x) { return std::isfinite(x); }
TG_NODISCARD inline bool is_finite(f64 x) { return std::isfinite(x); } [[nodiscard]] inline bool is_finite(f64 x) { return std::isfinite(x); }
TG_NODISCARD inline bool is_normal(f32 x) { return std::isnormal(x); } [[nodiscard]] inline bool is_normal(f32 x) { return std::isnormal(x); }
TG_NODISCARD inline bool is_normal(f64 x) { return std::isnormal(x); } [[nodiscard]] inline bool is_normal(f64 x) { return std::isnormal(x); }
TG_NODISCARD inline bool is_subnormal(f32 x) { return is_finite(x) && !is_normal(x); } [[nodiscard]] inline bool is_subnormal(f32 x) { return is_finite(x) && !is_normal(x); }
TG_NODISCARD inline bool is_subnormal(f64 x) { return is_finite(x) && !is_normal(x); } [[nodiscard]] inline bool is_subnormal(f64 x) { return is_finite(x) && !is_normal(x); }
enum class fp_class enum class fp_class
{ {
...@@ -56,7 +56,7 @@ enum class fp_class ...@@ -56,7 +56,7 @@ enum class fp_class
zero zero
}; };
TG_NODISCARD inline fp_class fp_classify(f32 x) [[nodiscard]] inline fp_class fp_classify(f32 x)
{ {
if (is_nan(x)) if (is_nan(x))
return fp_class::nan; return fp_class::nan;
...@@ -69,7 +69,7 @@ TG_NODISCARD inline fp_class fp_classify(f32 x) ...@@ -69,7 +69,7 @@ TG_NODISCARD inline fp_class fp_classify(f32 x)
else else
return fp_class::subnormal; return fp_class::subnormal;
} }
TG_NODISCARD inline fp_class fp_classify(f64 x) [[nodiscard]] inline fp_class fp_classify(f64 x)
{ {
if (is_nan(x)) if (is_nan(x))
return fp_class::nan; return fp_class::nan;
...@@ -87,70 +87,70 @@ TG_NODISCARD inline fp_class fp_classify(f64 x) ...@@ -87,70 +87,70 @@ TG_NODISCARD inline fp_class fp_classify(f64 x)
// Basics // Basics
// -i8 is i32 consistent with C++ // -i8 is i32 consistent with C++
TG_NODISCARD inline i32 abs(i8 v) { return v < 0 ? -v : v; } [[nodiscard]] inline i32 abs(i8 v) { return v < 0 ? -v : v; }
TG_NODISCARD inline i32 abs(i16 v) { return v < 0 ? -v : v; } [[nodiscard]] inline i32 abs(i16 v) { return v < 0 ? -v : v; }
TG_NODISCARD inline i32 abs(i32 v) { return v < 0 ? -v : v; } [[nodiscard]] inline i32 abs(i32 v) { return v < 0 ? -v : v; }
TG_NODISCARD inline i64 abs(i64 v) { return v < 0 ? -v : v; } [[nodiscard]] inline i64 abs(i64 v) { return v < 0 ? -v : v; }
TG_NODISCARD inline u8 abs(u8 v) { return v; } [[nodiscard]] inline u8 abs(u8 v) { return v; }
TG_NODISCARD inline u16 abs(u16 v) { return v; } [[nodiscard]] inline u16 abs(u16 v) { return v; }
TG_NODISCARD inline u32 abs(u32 v) { return v; } [[nodiscard]] inline u32 abs(u32 v) { return v; }
TG_NODISCARD inline u64 abs(u64 v) { return v; } [[nodiscard]] inline u64 abs(u64 v) { return v; }
TG_NODISCARD inline f8 abs(f8 v) { return v; } [[nodiscard]] inline f8 abs(f8 v) { return v; }
TG_NODISCARD inline f16 abs(f16 v) { return std::abs(v); } [[nodiscard]] inline f16 abs(f16 v) { return std::abs(v); }
TG_NODISCARD inline f32 abs(f32 v) { return std::abs(v); } [[nodiscard]] inline f32 abs(f32 v) { return std::abs(v); }
TG_NODISCARD inline f64 abs(f64 v) { return std::abs(v); } [[nodiscard]] inline f64 abs(f64 v) { return std::abs(v); }
template <class T> template <class T>
TG_NODISCARD angle_t<T> abs(angle_t<T> a) [[nodiscard]] angle_t<T> abs(angle_t<T> a)
{ {
return radians(abs(a.radians())); return radians(abs(a.radians()));
} }
TG_NODISCARD inline f32 floor(f32 v) { return std::floor(v); } [[nodiscard]] inline f32 floor(f32 v) { return std::floor(v); }
TG_NODISCARD inline f64 floor(f64 v) { return std::floor(v); } [[nodiscard]] inline f64 floor(f64 v) { return std::floor(v); }
TG_NODISCARD inline i32 ifloor(f32 v) { return v >= 0 || f32(i32(v)) == v ? i32(v) : i32(v) - 1; } [[nodiscard]] inline i32 ifloor(f32 v) { return v >= 0 || f32(i32(v)) == v ? i32(v) : i32(v) - 1; }
TG_NODISCARD inline i64 ifloor(f64 v) { return v >= 0 || f64(i64(v)) == v ? i64(v) : i64(v) - 1; } [[nodiscard]] inline i64 ifloor(f64 v) { return v >= 0 || f64(i64(v)) == v ? i64(v) : i64(v) - 1; }
TG_NODISCARD inline f32 ceil(f32 v) { return std::ceil(v); } [[nodiscard]] inline f32 ceil(f32 v) { return std::ceil(v); }
TG_NODISCARD inline f64 ceil(f64 v) { return std::ceil(v); } [[nodiscard]] inline f64 ceil(f64 v) { return std::ceil(v); }
TG_NODISCARD inline i32 iceil(f32 v) { return v <= 0 || f32(i32(v)) == v ? i32(v) : i32(v) + 1; } [[nodiscard]] inline i32 iceil(f32 v) { return v <= 0 || f32(i32(v)) == v ? i32(v) : i32(v) + 1; }
TG_NODISCARD inline i64 iceil(f64 v) { return v <= 0 || f64(i64(v)) == v ? i64(v) : i64(v) + 1; } [[nodiscard]] inline i64 iceil(f64 v) { return v <= 0 || f64(i64(v)) == v ? i64(v) : i64(v) + 1; }
TG_NODISCARD inline f32 round(f32 v) { return std::round(v); } [[nodiscard]] inline f32 round(f32 v) { return std::round(v); }
TG_NODISCARD inline f64 round(f64 v) { return std::round(v); } [[nodiscard]] inline f64 round(f64 v) { return std::round(v); }
TG_NODISCARD inline i32 iround(f32 v) { return v >= 0 ? i32(v + 0.5f) : i32(v - 0.5f); } [[nodiscard]] inline i32 iround(f32 v) { return v >= 0 ? i32(v + 0.5f) : i32(v - 0.5f); }
TG_NODISCARD inline i64 iround(f64 v) { return v >= 0 ? i64(v + 0.5) : i64(v - 0.5); } [[nodiscard]] inline i64 iround(f64 v) { return v >= 0 ? i64(v + 0.5) : i64(v - 0.5); }
TG_NODISCARD inline f32 fract(f32 v) { return v - floor(v); } [[nodiscard]] inline f32 fract(f32 v) { return v - floor(v); }
TG_NODISCARD inline f64 fract(f64 v) { return v - floor(v); } [[nodiscard]] inline f64 fract(f64 v) { return v - floor(v); }
template <class A, class B> template <class A, class B>
TG_NODISCARD constexpr auto min(A&& a, B&& b) -> decltype(a < b ? a : b) [[nodiscard]] constexpr auto min(A&& a, B&& b) -> decltype(a < b ? a : b)
{ {
return a < b ? a : b; return a < b ? a : b;
} }
template <class A, class B> template <class A, class B>
TG_NODISCARD constexpr auto max(A&& a, B&& b) -> decltype(a < b ? b : a) [[nodiscard]] constexpr auto max(A&& a, B&& b) -> decltype(a < b ? b : a)
{ {
return a < b ? b : a; return a < b ? b : a;
} }
template <class A, class B, class C> template <class A, class B, class C>
TG_NODISCARD constexpr auto clamp(A const& a, B const& min_value, C const& max_value) -> decltype(min(max(a, min_value), max_value)) [[nodiscard]] constexpr auto clamp(A const& a, B const& min_value, C const& max_value) -> decltype(min(max(a, min_value), max_value))
{ {
return min(max(a, min_value), max_value); return min(max(a, min_value), max_value);
} }
template <class T> template <class T>
TG_NODISCARD constexpr T saturate(T const& a) [[nodiscard]] constexpr T saturate(T const& a)
{ {
return clamp(a, T(0), T(1)); return clamp(a, T(0), T(1));
} }
template <class T, class = enable_if<is_scalar<T>>> template <class T, class = enable_if<is_scalar<T>>>
TG_NODISCARD constexpr T sign(T const& v) [[nodiscard]] constexpr T sign(T const& v)
{ {
// TODO: optimize? // TODO: optimize?
// if constexpr (!is_unsigned_integer<T>) // if constexpr (!is_unsigned_integer<T>)
...@@ -164,109 +164,109 @@ TG_NODISCARD constexpr T sign(T const& v) ...@@ -164,109 +164,109 @@ TG_NODISCARD constexpr T sign(T const& v)
// ================================================================== // ==================================================================
// Powers // Powers
TG_NODISCARD inline f32 pow(f32 b, f32 e) { return std::pow(b, e); } [[nodiscard]] inline f32 pow(f32 b, f32 e) { return std::pow(b, e); }
TG_NODISCARD inline f32 pow(f32 b, i32 e) { return f32(std::pow(b, e)); } [[nodiscard]] inline f32 pow(f32 b, i32 e) { return f32(std::pow(b, e)); }
TG_NODISCARD inline f64 pow(f64 b, f64 e) { return std::pow(b, e); } [[nodiscard]] inline f64 pow(f64 b, f64 e) { return std::pow(b, e); }
TG_NODISCARD inline f64 pow(f64 b, i32 e) { return std::pow(b, e); } [[nodiscard]] inline f64 pow(f64 b, i32 e) { return std::pow(b, e); }
template <class T> template <class T>
TG_NODISCARD constexpr auto pow2(T const& v) -> decltype(v * v) [[nodiscard]] constexpr auto pow2(T const& v) -> decltype(v * v)
{ {
return v * v; return v * v;
} }
template <class T> template <class T>
TG_NODISCARD constexpr auto pow3(T const& v) -> decltype(v * v * v) [[nodiscard]] constexpr auto pow3(T const& v) -> decltype(v * v * v)
{ {
return v * v * v; return v * v * v;
} }
template <class T> template <class T>
TG_NODISCARD constexpr auto pow4(T const& v) -> decltype((v * v) * (v * v)) [[nodiscard]] constexpr auto pow4(T const& v) -> decltype((v * v) * (v * v))
{ {
auto const v2 = v * v; auto const v2 = v * v;
return v2 * v2; return v2 * v2;
} }
template <class T> template <class T>
TG_NODISCARD constexpr auto pow5(T const& v) -> decltype((v * v) * (v * v) * v) [[nodiscard]] constexpr auto pow5(T const& v) -> decltype((v * v) * (v * v) * v)
{ {
auto const v2 = v * v; auto const v2 = v * v;
return v2 * v2 * v; return v2 * v2 * v;
} }
TG_NODISCARD inline f32 sqrt(f32 v) { return std::sqrt(v); } [[nodiscard]] inline f32 sqrt(f32 v) { return std::sqrt(v); }
TG_NODISCARD inline f64 sqrt(f64 v) { return std::sqrt(v); } [[nodiscard]] inline f64 sqrt(f64 v) { return std::sqrt(v); }
// TODO: _mm_rsqrt_ss // TODO: _mm_rsqrt_ss
TG_NODISCARD inline f32 rsqrt(f32 v) { return 1 / std::sqrt(v); } [[nodiscard]] inline f32 rsqrt(f32 v) { return 1 / std::sqrt(v); }
TG_NODISCARD inline f64 rsqrt(f64 v) { return 1 / std::sqrt(v); } [[nodiscard]] inline f64 rsqrt(f64 v) { return 1 / std::sqrt(v); }
TG_NODISCARD inline f32 cbrt(f32 v) { return std::cbrt(v); } [[nodiscard]] inline f32 cbrt(f32 v) { return std::cbrt(v); }
TG_NODISCARD inline f64 cbrt(f64 v) { return std::cbrt(v); } [[nodiscard]] inline f64 cbrt(f64 v) { return std::cbrt(v); }
// ================================================================== // ==================================================================
// Exponentials // Exponentials
TG_NODISCARD inline f32 exp(f32 v) { return std::exp(v); } [[nodiscard]] inline f32 exp(f32 v) { return std::exp(v); }
TG_NODISCARD inline f64 exp(f64 v) { return std::exp(v); } [[nodiscard]] inline f64 exp(f64 v) { return std::exp(v); }
TG_NODISCARD inline f32 exp2(f32 v) { return std::exp2(v); } [[nodiscard]] inline f32 exp2(f32 v) { return std::exp2(v); }
TG_NODISCARD inline f64 exp2(f64 v) { return std::exp2(v); } [[nodiscard]] inline f64 exp2(f64 v) { return std::exp2(v); }
TG_NODISCARD inline f32 log(f32 v) { return std::log(v); } [[nodiscard]] inline f32 log(f32 v) { return std::log(v); }
TG_NODISCARD inline f64 log(f64 v) { return std::log(v); } [[nodiscard]] inline f64 log(f64 v) { return std::log(v); }
TG_NODISCARD inline f32 log2(f32 v) { return std::log2(v); } [[nodiscard]] inline f32 log2(f32 v) { return std::log2(v); }
TG_NODISCARD inline f64 log2(f64 v) { return std::log2(v); } [[nodiscard]] inline f64 log2(f64 v) { return std::log2(v); }
TG_NODISCARD inline f32 log10(f32 v) { return std::log10(v); } [[nodiscard]] inline f32 log10(f32 v) { return std::log10(v); }
TG_NODISCARD inline f64 log10(f64 v) { return std::log10(v); } [[nodiscard]] inline f64 log10(f64 v) { return std::log10(v); }
// ================================================================== // ==================================================================
// Trigonometry // Trigonometry
TG_NODISCARD inline f32 sin(angle_t<f32> v) { return std::sin(v.radians()); } [[nodiscard]] inline f32 sin(angle_t<f32> v) { return std::sin(v.radians()); }
TG_NODISCARD inline f64 sin(angle_t<f64> v) { return std::sin(v.radians()); } [[nodiscard]] inline f64 sin(angle_t<f64> v) { return std::sin(v.radians()); }
TG_NODISCARD inline f32 cos(angle_t<f32> v) { return std::cos(v.radians()); } [[nodiscard]] inline f32 cos(angle_t<f32> v) { return std::cos(v.radians()); }
TG_NODISCARD inline f64 cos(angle_t<f64> v) { return std::cos(v.radians()); } [[nodiscard]] inline f64 cos(angle_t<f64> v) { return std::cos(v.radians()); }
TG_NODISCARD inline f32 tan(angle_t<f32> v) { return std::tan(v.radians()); } [[nodiscard]] inline f32 tan(angle_t<f32> v) { return std::tan(v.radians()); }
TG_NODISCARD inline f64 tan(angle_t<f64> v) { return std::tan(v.radians()); } [[nodiscard]] inline f64 tan(angle_t<f64> v) { return std::tan(v.radians()); }
// TODO: use SSE intrinsic to compute both directly // TODO: use SSE intrinsic to compute both directly
TG_NODISCARD inline pair<f32, f32> sin_cos(angle_t<f32> v) { return {sin(v), cos(v)}; } [[nodiscard]] inline pair<f32, f32> sin_cos(angle_t<f32> v) { return {sin(v), cos(v)}; }
TG_NODISCARD inline pair<f64, f64> sin_cos(angle_t<f64> v) { return {sin(v), cos(v)}; } [[nodiscard]] inline pair<f64, f64> sin_cos(angle_t<f64> v) { return {sin(v), cos(v)}; }
TG_NODISCARD inline angle_t<f32> asin(f32 v) { return radians(std::asin(v)); } [[nodiscard]] inline angle_t<f32> asin(f32 v) { return radians(std::asin(v)); }
TG_NODISCARD inline angle_t<f64> asin(f64 v) { return radians(std::asin(v)); } [[nodiscard]] inline angle_t<f64> asin(f64 v) { return radians(std::asin(v)); }
TG_NODISCARD inline angle_t<f32> acos(f32 v) { return radians(std::acos(v)); } [[nodiscard]] inline angle_t<f32> acos(f32 v) { return radians(std::acos(v)); }
TG_NODISCARD inline angle_t<f64> acos(f64 v) { return radians(std::acos(v)); } [[nodiscard]] inline angle_t<f64> acos(f64 v) { return radians(std::acos(v)); }
TG_NODISCARD inline angle_t<f32> atan(f32 v) { return radians(std::atan(v)); } [[nodiscard]] inline angle_t<f32> atan(f32 v) { return radians(std::atan(v)); }
TG_NODISCARD inline angle_t<f64> atan(f64 v) { return radians(std::atan(v)); } [[nodiscard]] inline angle_t<f64> atan(f64 v) { return radians(std::atan(v)); }
TG_NODISCARD inline angle_t<f32> atan2(f32 y, f32 x) { return radians(std::atan2(y, x)); } [[nodiscard]] inline angle_t<f32> atan2(f32 y, f32 x) { return radians(std::atan2(y, x)); }
TG_NODISCARD inline angle_t<f64> atan2(f64 y, f64 x) { return radians(std::atan2(y, x)); } [[nodiscard]] inline angle_t<f64> atan2(f64 y, f64 x) { return radians(std::atan2(y, x)); }
TG_NODISCARD inline f32 sinh(f32 v) { return std::sinh(v); } [[nodiscard]] inline f32 sinh(f32 v) { return std::sinh(v); }
TG_NODISCARD inline f64 sinh(f64 v) { return std::sinh(v); } [[nodiscard]] inline f64 sinh(f64 v) { return std::sinh(v); }
TG_NODISCARD inline f32 cosh(f32 v) { return std::cosh(v); } [[nodiscard]] inline f32 cosh(f32 v) { return std::cosh(v); }
TG_NODISCARD inline f64 cosh(f64 v) { return std::cosh(v); } [[nodiscard]] inline f64 cosh(f64 v) { return std::cosh(v); }
TG_NODISCARD inline f32 tanh(f32 v) { return std::tanh(v); } [[nodiscard]] inline f32 tanh(f32 v) { return std::tanh(v); }
TG_NODISCARD inline f64 tanh(f64 v) { return std::tanh(v); } [[nodiscard]] inline f64 tanh(f64 v) { return std::tanh(v); }
TG_NODISCARD inline f32 asinh(f32 v) { return std::asinh(v); } [[nodiscard]] inline f32 asinh(f32 v) { return std::asinh(v); }
TG_NODISCARD inline f64 asinh(f64 v) { return std::asinh(v); } [[nodiscard]] inline f64 asinh(f64 v) { return std::asinh(v); }
TG_NODISCARD inline f32 acosh(f32 v) { return std::acosh(v); } [[nodiscard]] inline f32 acosh(f32 v) { return std::acosh(v); }
TG_NODISCARD inline f64 acosh(f64 v) { return std::acosh(v); } [[nodiscard]] inline f64 acosh(f64 v) { return std::acosh(v); }
TG_NODISCARD inline f32 atanh(f32 v) { return std::atanh(v); } [[nodiscard]] inline f32 atanh(f32 v) { return std::atanh(v); }
TG_NODISCARD inline f64 atanh(f64 v) { return std::atanh(v); } [[nodiscard]] inline f64 atanh(f64 v) { return std::atanh(v); }
// ================================================================== // ==================================================================
// other GLSL // other GLSL
TG_NODISCARD constexpr f32 smoothstep(f32 edge0, f32 edge1, f32 x) [[nodiscard]] constexpr f32 smoothstep(f32 edge0, f32 edge1, f32 x)
{ {
auto t = clamp((x - edge0) / (edge1 - edge0), f32(0), f32(1)); auto t = clamp((x - edge0) / (edge1 - edge0), f32(0), f32(1));
return t * t * (f32(3) - f32(2) * t); return t * t * (f32(3) - f32(2) * t);
} }
TG_NODISCARD constexpr f64 smoothstep(f64 edge0, f64 edge1, f64 x) [[nodiscard]] constexpr f64 smoothstep(f64 edge0, f64 edge1, f64 x)
{ {
auto t = clamp((x - edge0) / (edge1 - edge0), f64(0), f64(1)); auto t = clamp((x - edge0) / (edge1 - edge0), f64(0), f64(1));
return t * t * (f64(3) - f64(2) * t); return t * t * (f64(3) - f64(2) * t);
......
...@@ -16,9 +16,9 @@ struct base_swizzle_proxy ...@@ -16,9 +16,9 @@ struct base_swizzle_proxy
using comp_t = CompTemplate<D, ScalarT>; using comp_t = CompTemplate<D, ScalarT>;
using other_comp_t = CompTemplate<sizeof...(Indices), ScalarT>; using other_comp_t = CompTemplate<sizeof...(Indices), ScalarT>;
TG_NODISCARD constexpr operator other_comp_t() const { return other_comp_t(ref[Indices]...); } [[nodiscard]] constexpr operator other_comp_t() const { return other_comp_t(ref[Indices]...); }
template <class OtherT> template <class OtherT>
TG_NODISCARD explicit constexpr operator OtherT() const [[nodiscard]] explicit constexpr operator OtherT() const
{ {
return OtherT(ref[Indices]...); return OtherT(ref[Indices]...);
} }
...@@ -67,7 +67,7 @@ struct swizzler ...@@ -67,7 +67,7 @@ struct swizzler
{ {
// directly apply swizzling // directly apply swizzling
template <template <int, class> class CompT, int D, class ScalarT> template <template <int, class> class CompT, int D, class ScalarT>
TG_NODISCARD constexpr CompT<sizeof...(Indices), ScalarT> const operator()(CompT<D, ScalarT> const& v) const [[nodiscard]] constexpr CompT<sizeof...(Indices), ScalarT> const operator()(CompT<D, ScalarT> const& v) const
{ {
#if !defined(_MSC_VER) || _MSC_VER >= 1920 #if !defined(_MSC_VER) || _MSC_VER >= 1920
static_assert((... && (0 <= Indices && Indices < D)), "swizzle index out of range"); static_assert((... && (0 <= Indices && Indices < D)), "swizzle index out of range");
...@@ -77,22 +77,22 @@ struct swizzler ...@@ -77,22 +77,22 @@ struct swizzler
// return proxy object to allow assignment // return proxy object to allow assignment
template <template <int, class> class CompT, int D, class ScalarT> template <template <int, class> class CompT, int D, class ScalarT>
TG_NODISCARD constexpr detail::mutable_swizzle_proxy<CompT, D, ScalarT, Indices...> operator[](CompT<D, ScalarT>& v) const [[nodiscard]] constexpr detail::mutable_swizzle_proxy<CompT, D, ScalarT, Indices...> operator[](CompT<D, ScalarT>& v) const
{ {
return detail::mutable_swizzle_proxy<CompT, D, ScalarT, Indices...>(v); return detail::mutable_swizzle_proxy<CompT, D, ScalarT, Indices...>(v);
} }
template <template <int, class> class CompT, int D, class ScalarT> template <template <int, class> class CompT, int D, class ScalarT>
TG_NODISCARD constexpr detail::const_swizzle_proxy<CompT, D, ScalarT, Indices...> operator[](CompT<D, ScalarT> const& v) const [[nodiscard]] constexpr detail::const_swizzle_proxy<CompT, D, ScalarT, Indices...> operator[](CompT<D, ScalarT> const& v) const
{ {
return detail::const_swizzle_proxy<CompT, D, ScalarT, Indices...>(v); return detail::const_swizzle_proxy<CompT, D, ScalarT, Indices...>(v);
} }
template <template <int, class> class CompT, int D, class ScalarT> template <template <int, class> class CompT, int D, class ScalarT>
TG_NODISCARD constexpr detail::owning_swizzle_proxy<CompT, D, ScalarT, Indices...> operator[](CompT<D, ScalarT>&& v) const [[nodiscard]] constexpr detail::owning_swizzle_proxy<CompT, D, ScalarT, Indices...> operator[](CompT<D, ScalarT>&& v) const
{ {
return detail::owning_swizzle_proxy<CompT, D, ScalarT, Indices...>(static_cast<CompT<D, ScalarT>&&>(v)); return detail::owning_swizzle_proxy<CompT, D, ScalarT, Indices...>(static_cast<CompT<D, ScalarT>&&>(v));
} }
template <template <int, class> class CompT, int D, class ScalarT> template <template <int, class> class CompT, int D, class ScalarT>
TG_NODISCARD constexpr detail::owning_swizzle_proxy<CompT, D, ScalarT, Indices...> operator[](CompT<D, ScalarT> const&& v) const [[nodiscard]] constexpr detail::owning_swizzle_proxy<CompT, D, ScalarT, Indices...> operator[](CompT<D, ScalarT> const&& v) const
{ {
return detail::owning_swizzle_proxy<CompT, D, ScalarT, Indices...>(v); return detail::owning_swizzle_proxy<CompT, D, ScalarT, Indices...>(v);
} }
......
...@@ -55,8 +55,6 @@ ...@@ -55,8 +55,6 @@
#define TG_FORCE_SEMICOLON static_assert(true) #define TG_FORCE_SEMICOLON static_assert(true)
// currently a macro because clang-format interacts badly with it
#define TG_NODISCARD [[nodiscard]]
// ========= // =========
// operations and classes // operations and classes
...@@ -125,17 +123,17 @@ ...@@ -125,17 +123,17 @@
#define TG_DECLARE_SELF_SWIZZLE(TYPE) \ #define TG_DECLARE_SELF_SWIZZLE(TYPE) \
template <int... Indices> \ template <int... Indices> \
TG_NODISCARD constexpr auto operator[](swizzler<Indices...> const& swizzle) \ [[nodiscard]] constexpr auto operator[](swizzler<Indices...> const& swizzle) \
{ \ { \
return swizzle[*this]; \ return swizzle[*this]; \
} \ } \
template <int... Indices> \ template <int... Indices> \
TG_NODISCARD constexpr auto operator[](swizzler<Indices...> const& swizzle) const \ [[nodiscard]] constexpr auto operator[](swizzler<Indices...> const& swizzle) const \
{ \ { \
return swizzle[*this]; \ return swizzle[*this]; \
} \ } \
template <int... Indices> \ template <int... Indices> \
TG_NODISCARD constexpr TYPE<sizeof...(Indices), ScalarT> const operator()(swizzler<Indices...> const& swizzle) const \ [[nodiscard]] constexpr TYPE<sizeof...(Indices), ScalarT> const operator()(swizzler<Indices...> const& swizzle) const \
{ \ { \
return swizzle(*this); \ return swizzle(*this); \
} \ } \
...@@ -241,7 +239,7 @@ ...@@ -241,7 +239,7 @@
#define TG_IMPL_DEFINE_UNARY_OP(TYPE, OP) \ #define TG_IMPL_DEFINE_UNARY_OP(TYPE, OP) \
template <int D, class ScalarT> \ template <int D, class ScalarT> \