Browse Source

Ignore Clang's -Wdeprecated-literal-operator until we can drop GCC 4.8.

And also remove the other space, to be consistent with Doxygen links,
what Corrade uses, and have the literals easier to search for.
pull/364/merge
Vladimír Vondruš 2 years ago
parent
commit
cce12a27fb
  1. 36
      src/Magnum/Math/Angle.h
  2. 30
      src/Magnum/Math/Color.h
  3. 16
      src/Magnum/Math/Half.h
  4. 22
      src/Magnum/Math/Time.h

36
src/Magnum/Math/Angle.h

@ -157,6 +157,17 @@ namespace Literals {
#endif
namespace AngleLiterals {
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and 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
/** @relatesalso Magnum::Math::Deg
@brief Double-precision degree value literal
@ -167,7 +178,7 @@ Example usage:
@see @link operator""_degf() @endlink, @link operator""_rad() @endlink
@m_keywords{_deg deg}
*/
constexpr Deg<Double> operator "" _deg(long double value) { return Deg<Double>(Double(value)); }
constexpr Deg<Double> operator"" _deg(long double value) { return Deg<Double>(Double(value)); }
/** @relatesalso Magnum::Math::Deg
@brief Single-precision degree value literal
@ -179,7 +190,10 @@ Example usage:
@see @link operator""_deg() @endlink, @link operator""_radf() @endlink
@m_keywords{_degf degf}
*/
constexpr Deg<Float> operator "" _degf(long double value) { return Deg<Float>(Float(value)); }
constexpr Deg<Float> operator"" _degf(long double value) { return Deg<Float>(Float(value)); }
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}}
@ -246,6 +260,17 @@ namespace Literals {
#endif
namespace AngleLiterals {
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and 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
/** @relatesalso Magnum::Math::Rad
@brief Double-precision radian value literal
@ -253,7 +278,7 @@ See @link operator""_deg() @endlink for more information.
@see @link operator""_radf() @endlink
@m_keywords{_rad rad}
*/
constexpr Rad<Double> operator "" _rad(long double value) { return Rad<Double>(Double(value)); }
constexpr Rad<Double> operator"" _rad(long double value) { return Rad<Double>(Double(value)); }
/** @relatesalso Magnum::Math::Rad
@brief Single-precision radian value literal
@ -262,7 +287,10 @@ See @link operator""_degf() @endlink for more information.
@see @link operator""_rad() @endlink
@m_keywords{_radf radf}
*/
constexpr Rad<Float> operator "" _radf(long double value) { return Rad<Float>(Float(value)); }
constexpr Rad<Float> operator"" _radf(long double value) { return Rad<Float>(Float(value)); }
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}}

30
src/Magnum/Math/Color.h

@ -1325,6 +1325,17 @@ namespace Literals {
#endif
namespace ColorLiterals {
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and 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
/** @relatesalso Magnum::Math::Color3
@brief 8bit-per-channel linear RGB literal
@ -1340,7 +1351,7 @@ Unpacks the literal into three 8-bit values. Example usage:
@see @link operator""_rgba() @endlink, @link operator""_rgbf() @endlink
@m_keywords{_rgb rgb}
*/
constexpr Color3<UnsignedByte> operator "" _rgb(unsigned long long value) {
constexpr Color3<UnsignedByte> operator"" _rgb(unsigned long long value) {
return {UnsignedByte(value >> 16), UnsignedByte(value >> 8), UnsignedByte(value)};
}
@ -1366,7 +1377,7 @@ RGB. Use this literal to document that given value is in sRGB. Example usage:
*/
/* Output is a Vector3 to hint that it doesn't have any (additive,
multiplicative) semantics of a linear RGB color */
constexpr Vector3<UnsignedByte> operator "" _srgb(unsigned long long value) {
constexpr Vector3<UnsignedByte> operator"" _srgb(unsigned long long value) {
return {UnsignedByte(value >> 16), UnsignedByte(value >> 8), UnsignedByte(value)};
}
@ -1385,7 +1396,7 @@ Unpacks the literal into four 8-bit values. Example usage:
@see @link operator""_rgb() @endlink, @link operator""_rgbaf() @endlink
@m_keywords{_rgba rgba}
*/
constexpr Color4<UnsignedByte> operator "" _rgba(unsigned long long value) {
constexpr Color4<UnsignedByte> operator"" _rgba(unsigned long long value) {
return {UnsignedByte(value >> 24), UnsignedByte(value >> 16), UnsignedByte(value >> 8), UnsignedByte(value)};
}
@ -1412,7 +1423,7 @@ usage:
*/
/* Output is a Vector3 to hint that it doesn't have any (additive,
multiplicative) semantics of a linear RGB color */
constexpr Vector4<UnsignedByte> operator "" _srgba(unsigned long long value) {
constexpr Vector4<UnsignedByte> operator"" _srgba(unsigned long long value) {
return {UnsignedByte(value >> 24), UnsignedByte(value >> 16), UnsignedByte(value >> 8), UnsignedByte(value)};
}
@ -1432,7 +1443,7 @@ Example usage:
@see @link operator""_rgbaf() @endlink, @link operator""_rgb() @endlink
@m_keywords{_rgbf rgbf}
*/
constexpr Color3<Float> operator "" _rgbf(unsigned long long value) {
constexpr Color3<Float> operator"" _rgbf(unsigned long long value) {
return {((value >> 16) & 0xff)/255.0f,
((value >> 8) & 0xff)/255.0f,
((value >> 0) & 0xff)/255.0f};
@ -1449,7 +1460,7 @@ Calls @ref Color3::fromSrgbInt() on the literal value. Example usage:
@link operator""_rgbf() @endlink
@m_keywords{_srgbf srgbf}
*/
inline Color3<Float> operator "" _srgbf(unsigned long long value) {
inline Color3<Float> operator"" _srgbf(unsigned long long value) {
return Color3<Float>::fromSrgbInt(UnsignedInt(value));
}
@ -1469,7 +1480,7 @@ Example usage:
@see @link operator""_rgbf() @endlink, @link operator""_rgba() @endlink
@m_keywords{_rgbaf rgbaf}
*/
constexpr Color4<Float> operator "" _rgbaf(unsigned long long value) {
constexpr Color4<Float> operator"" _rgbaf(unsigned long long value) {
return {((value >> 24) & 0xff)/255.0f,
((value >> 16) & 0xff)/255.0f,
((value >> 8) & 0xff)/255.0f,
@ -1487,9 +1498,12 @@ Calls @ref Color4::fromSrgbAlphaInt() on the literal value. Example usage:
@link operator""_rgbaf() @endlink
@m_keywords{_srgbaf srgbaf}
*/
inline Color4<Float> operator "" _srgbaf(unsigned long long value) {
inline Color4<Float> operator"" _srgbaf(unsigned long long value) {
return Color4<Float>::fromSrgbAlphaInt(UnsignedInt(value));
}
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}}

16
src/Magnum/Math/Half.h

@ -183,12 +183,26 @@ namespace Literals {
#endif
namespace HalfLiterals {
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and 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
/** @relatesalso Magnum::Math::Half
@brief Half-float literal
See @ref Half for more information.
*/
inline Half operator "" _h(long double value) { return Half(Float(value)); }
inline Half operator"" _h(long double value) { return Half(Float(value)); }
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}}

22
src/Magnum/Math/Time.h

@ -288,6 +288,17 @@ namespace Literals {
everything already. Seeing 15.0_sec in unfamiliar code doesn't feel
ambiguous, seeing 127_s or 0.5_h definitely does. */
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and 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
/** @relatesalso Magnum::Math::Nanoseconds
@brief Nanosecond value literal
@m_since_latest
@ -302,7 +313,7 @@ fractions of nanoseconds. Usage example:
@link operator""_sec() @endlink
@m_keywords{_nsec nsec}
*/
constexpr Nanoseconds<Long> operator "" _nsec(unsigned long long value) {
constexpr Nanoseconds<Long> operator"" _nsec(unsigned long long value) {
return Nanoseconds<Long>{Long(value)};
}
@ -325,7 +336,7 @@ precision on a range of roughly ±8 seconds. For example:
@ref CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE
@m_keywords{_usec usec}
*/
constexpr Nanoseconds<Long> operator "" _usec(long double value) {
constexpr Nanoseconds<Long> operator"" _usec(long double value) {
return Nanoseconds<Long>{Long(value*1000.0l)};
}
@ -348,7 +359,7 @@ precision on a range of roughly ±2 hours. For example:
@ref CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE
@m_keywords{_msec msec}
*/
constexpr Nanoseconds<Long> operator "" _msec(long double value) {
constexpr Nanoseconds<Long> operator"" _msec(long double value) {
return Nanoseconds<Long>{Long(value*1000000.0l)};
}
@ -371,9 +382,12 @@ precision on a range of roughly ±2 hours. For example:
@ref CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE
@m_keywords{_sec sec}
*/
constexpr Nanoseconds<Long> operator "" _sec(long double value) {
constexpr Nanoseconds<Long> operator"" _sec(long double value) {
return Nanoseconds<Long>{Long(value*1000000000.0l)};
}
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}}

Loading…
Cancel
Save