Browse Source

GCC 4.6 compatibility: no user-defined literals.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
2cdb159cbd
  1. 4
      src/Magnum.h
  2. 1
      src/Math/Angle.h
  3. 4
      src/Math/Test/AngleTest.cpp

4
src/Magnum.h

@ -40,10 +40,12 @@ namespace Magnum {
namespace Math { namespace Math {
template<class T> struct Constants; template<class T> struct Constants;
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Rad<Double> operator "" _rad(long double); constexpr Rad<Double> operator "" _rad(long double);
constexpr Rad<Float> operator "" _radf(long double); constexpr Rad<Float> operator "" _radf(long double);
constexpr Deg<Double> operator "" _deg(long double); constexpr Deg<Double> operator "" _deg(long double);
constexpr Deg<Float> operator "" _degf(long double); constexpr Deg<Float> operator "" _degf(long double);
#endif
} }
/* Bring debugging facility from Corrade::Utility namespace */ /* Bring debugging facility from Corrade::Utility namespace */
@ -240,11 +242,13 @@ typedef Math::Geometry::Rectangle<Double> Rectangled;
/*@}*/ /*@}*/
#endif #endif
#ifndef CORRADE_GCC46_COMPATIBILITY
/* Using angle literals from Math namespace */ /* Using angle literals from Math namespace */
using Math::operator "" _deg; using Math::operator "" _deg;
using Math::operator "" _degf; using Math::operator "" _degf;
using Math::operator "" _rad; using Math::operator "" _rad;
using Math::operator "" _radf; using Math::operator "" _radf;
#endif
/** @todoc Remove `ifndef` when Doxygen is sane again */ /** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT

1
src/Math/Angle.h

@ -20,6 +20,7 @@
*/ */
#include <Utility/Debug.h> #include <Utility/Debug.h>
#include <corradeCompatibility.h>
#include "Math/Constants.h" #include "Math/Constants.h"
#include "Math/Math.h" #include "Math/Math.h"

4
src/Math/Test/AngleTest.cpp

@ -73,6 +73,7 @@ void AngleTest::construct() {
} }
void AngleTest::literals() { void AngleTest::literals() {
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr auto a = 25.0_deg; constexpr auto a = 25.0_deg;
constexpr auto b = 25.0_degf; constexpr auto b = 25.0_degf;
CORRADE_VERIFY((std::is_same<decltype(a), const Degd>::value)); CORRADE_VERIFY((std::is_same<decltype(a), const Degd>::value));
@ -86,6 +87,9 @@ void AngleTest::literals() {
CORRADE_VERIFY((std::is_same<decltype(n), const Rad>::value)); CORRADE_VERIFY((std::is_same<decltype(n), const Rad>::value));
CORRADE_COMPARE(Double(m), 3.14); CORRADE_COMPARE(Double(m), 3.14);
CORRADE_COMPARE(Float(n), 3.14f); CORRADE_COMPARE(Float(n), 3.14f);
#else
CORRADE_SKIP("User-defined literals are not available on GCC < 4.7.");
#endif
} }
void AngleTest::conversion() { void AngleTest::conversion() {

Loading…
Cancel
Save