Browse Source

Math: there's no reason to call the color literals like this.

pull/674/head
Vladimír Vondruš 1 year ago
parent
commit
e068d32ba2
  1. 82
      src/Magnum/Math/Color.cpp

82
src/Magnum/Math/Color.cpp

@ -173,23 +173,12 @@ Containers::Pair<TweakableState, Magnum::Math::Color3<Magnum::UnsignedByte>> Twe
return {TweakableState::Error, {}}; return {TweakableState::Error, {}};
} }
/* According to https://wg21.link/CWG2521, space between "" and literal /* Both the _srgba and _rgba literals return the same value (but a
name is deprecated because _Uppercase or __double names could be treated different type) as they're meant mainly for self-documenting purposes.
as reserved depending on whether the space was present or not, and So here's no distinction either, and fromLinearRgbInt() is just
whitespace is not load-bearing in any other contexts. Clang 17+ adds an splitting up the 24-bit integer to 8-bit parts. */
off-by-default warning for this; GCC 4.8 however *requires* the space
there, so until GCC 4.8 support is dropped, we suppress this warning
instead of removing the space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
return {TweakableState::Success, return {TweakableState::Success,
isSrgb ? Magnum::Math::Literals::operator"" _srgb(result) : Magnum::Math::Color3<Magnum::UnsignedByte>::fromLinearRgbInt(result)};
Magnum::Math::Literals::operator"" _rgb(result)};
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
} }
Containers::Pair<TweakableState, Magnum::Math::Color4<Magnum::UnsignedByte>> TweakableParser<Magnum::Math::Color4<Magnum::UnsignedByte>>::parse(const Containers::StringView value) { Containers::Pair<TweakableState, Magnum::Math::Color4<Magnum::UnsignedByte>> TweakableParser<Magnum::Math::Color4<Magnum::UnsignedByte>>::parse(const Containers::StringView value) {
@ -219,23 +208,12 @@ Containers::Pair<TweakableState, Magnum::Math::Color4<Magnum::UnsignedByte>> Twe
return {TweakableState::Error, {}}; return {TweakableState::Error, {}};
} }
/* According to https://wg21.link/CWG2521, space between "" and literal /* Both the _srgba and _rgba literals return the same value (but a
name is deprecated because _Uppercase or __double names could be treated different type) as they're meant mainly for self-documenting purposes.
as reserved depending on whether the space was present or not, and So here's no distinction either, and fromLinearRgbaInt() is just
whitespace is not load-bearing in any other contexts. Clang 17+ adds an splitting up the 32-bit integer to 8-bit parts. */
off-by-default warning for this; GCC 4.8 however *requires* the space
there, so until GCC 4.8 support is dropped, we suppress this warning
instead of removing the space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
return {TweakableState::Success, return {TweakableState::Success,
isSrgb ? Magnum::Math::Literals::operator"" _srgba(result) : Magnum::Math::Color4<Magnum::UnsignedByte>::fromLinearRgbaInt(result)};
Magnum::Math::Literals::operator"" _rgba(result)};
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
} }
Containers::Pair<TweakableState, Magnum::Math::Color3<Magnum::Float>> TweakableParser<Magnum::Math::Color3<Magnum::Float>>::parse(const Containers::StringView value) { Containers::Pair<TweakableState, Magnum::Math::Color3<Magnum::Float>> TweakableParser<Magnum::Math::Color3<Magnum::Float>>::parse(const Containers::StringView value) {
@ -265,23 +243,9 @@ Containers::Pair<TweakableState, Magnum::Math::Color3<Magnum::Float>> TweakableP
return {TweakableState::Error, {}}; return {TweakableState::Error, {}};
} }
/* According to https://wg21.link/CWG2521, space between "" and literal return {TweakableState::Success, isSrgb ?
name is deprecated because _Uppercase or __double names could be treated Magnum::Math::Color3<Magnum::Float>::fromSrgbInt(result) :
as reserved depending on whether the space was present or not, and Magnum::Math::Color3<Magnum::Float>::fromLinearRgbInt(result)};
whitespace is not load-bearing in any other contexts. Clang 17+ adds an
off-by-default warning for this; GCC 4.8 however *requires* the space
there, so until GCC 4.8 support is dropped, we suppress this warning
instead of removing the space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
return {TweakableState::Success,
isSrgb ? Magnum::Math::Literals::operator"" _srgbf(result) :
Magnum::Math::Literals::operator"" _rgbf(result)};
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
} }
Containers::Pair<TweakableState, Magnum::Math::Color4<Magnum::Float>> TweakableParser<Magnum::Math::Color4<Magnum::Float>>::parse(const Containers::StringView value) { Containers::Pair<TweakableState, Magnum::Math::Color4<Magnum::Float>> TweakableParser<Magnum::Math::Color4<Magnum::Float>>::parse(const Containers::StringView value) {
@ -311,23 +275,9 @@ Containers::Pair<TweakableState, Magnum::Math::Color4<Magnum::Float>> TweakableP
return {TweakableState::Error, {}}; return {TweakableState::Error, {}};
} }
/* According to https://wg21.link/CWG2521, space between "" and literal return {TweakableState::Success, isSrgb ?
name is deprecated because _Uppercase or __double names could be treated Magnum::Math::Color4<Magnum::Float>::fromSrgbAlphaInt(result) :
as reserved depending on whether the space was present or not, and Magnum::Math::Color4<Magnum::Float>::fromLinearRgbaInt(result)};
whitespace is not load-bearing in any other contexts. Clang 17+ adds an
off-by-default warning for this; GCC 4.8 however *requires* the space
there, so until GCC 4.8 support is dropped, we suppress this warning
instead of removing the space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
return {TweakableState::Success,
isSrgb ? Magnum::Math::Literals::operator"" _srgbaf(result) :
Magnum::Math::Literals::operator"" _rgbaf(result)};
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
} }
}} }}

Loading…
Cancel
Save