Browse Source

Math: mark scatter() with CORRADE_NODISCARD.

Spent quite a while figuring out why the call didn't work, only to
realize it doesn't modify the value in-place. This annotation should
help.
pull/686/head
Vladimír Vondruš 4 months ago
parent
commit
5ea9faef04
  1. 4
      src/Magnum/Math/Swizzle.h

4
src/Magnum/Math/Swizzle.h

@ -145,11 +145,11 @@ Inverse to @ref gather(), supporting the same component addressing except for
@ref Vector4::rgb(), @ref Vector4::xy(), @ref Vector3::xy() @ref Vector4::rgb(), @ref Vector4::xy(), @ref Vector3::xy()
*/ */
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
template<char ...components, class T> constexpr T scatter(const T& vector, const Vector<sizeof...(components), typename T::Type>& values) template<char ...components, class T> CORRADE_NODISCARD constexpr T scatter(const T& vector, const Vector<sizeof...(components), typename T::Type>& values)
#else #else
/* Using std::common_type otherwise GCC 4.8 fails to match the arguments /* Using std::common_type otherwise GCC 4.8 fails to match the arguments
in SwizzleTest::scatterOneComponent() */ in SwizzleTest::scatterOneComponent() */
template<char ...components, class T> constexpr T scatter(const T& vector, const typename std::common_type<Vector<sizeof...(components), typename T::Type>>::type& values) template<char ...components, class T> CORRADE_NODISCARD constexpr T scatter(const T& vector, const typename std::common_type<Vector<sizeof...(components), typename T::Type>>::type& values)
#endif #endif
{ {
return Implementation::scatterRecursive<T, sizeof...(components), components...>(vector, values, 0); return Implementation::scatterRecursive<T, sizeof...(components), components...>(vector, values, 0);

Loading…
Cancel
Save