|
|
|
|
@ -46,10 +46,7 @@ namespace Magnum { namespace Math {
|
|
|
|
|
namespace Implementation { |
|
|
|
|
|
|
|
|
|
template<> struct RangeConverter<1, Float, Dim> { |
|
|
|
|
#if !defined(__GNUC__) || defined(__clang__) |
|
|
|
|
constexpr /* See the convert() test case */ |
|
|
|
|
#endif |
|
|
|
|
static Range<1, Float> from(const Dim& other) { |
|
|
|
|
constexpr static Range<1, Float> from(const Dim& other) { |
|
|
|
|
/* Doing it this way to preserve constexpr */ |
|
|
|
|
return {other.offset, other.offset + other.size}; |
|
|
|
|
} |
|
|
|
|
@ -62,10 +59,7 @@ template<> struct RangeConverter<1, Float, Dim> {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template<> struct RangeConverter<2, Float, Rect> { |
|
|
|
|
#if !defined(__GNUC__) || defined(__clang__) |
|
|
|
|
constexpr /* See the convert() test case */ |
|
|
|
|
#endif |
|
|
|
|
static Range<2, Float> from(const Rect& other) { |
|
|
|
|
constexpr static Range<2, Float> from(const Rect& other) { |
|
|
|
|
/* Doing it this way to preserve constexpr */ |
|
|
|
|
return {{other.x, other.y}, {other.x + other.w, other.y + other.h}}; |
|
|
|
|
} |
|
|
|
|
@ -79,10 +73,7 @@ template<> struct RangeConverter<2, Float, Rect> {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template<> struct RangeConverter<3, Float, Box> { |
|
|
|
|
#if !defined(__GNUC__) || defined(__clang__) |
|
|
|
|
constexpr /* See the convert() test case */ |
|
|
|
|
#endif |
|
|
|
|
static Range<3, Float> from(const Box& other) { |
|
|
|
|
constexpr static Range<3, Float> from(const Box& other) { |
|
|
|
|
return {{other.x, other.y, other.z}, |
|
|
|
|
/* Doing it this way to preserve constexpr */ |
|
|
|
|
{other.x + other.w, |
|
|
|
|
@ -296,25 +287,12 @@ void RangeTest::convert() {
|
|
|
|
|
constexpr Range2D e{{1.5f, -2.0f}, {5.0f, -1.5f}}; |
|
|
|
|
constexpr Range3D f{{1.5f, -2.0f, -0.5f}, {5.0f, -1.5f, 9.0f}}; |
|
|
|
|
|
|
|
|
|
/* GCC 5.1 fills the result with zeros instead of properly calling
|
|
|
|
|
delegated copy constructor if using constexpr. Reported here: |
|
|
|
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */
|
|
|
|
|
#if !defined(__GNUC__) || defined(__clang__) |
|
|
|
|
constexpr |
|
|
|
|
#endif |
|
|
|
|
Range<2, Float> g{b}; |
|
|
|
|
#if !defined(__GNUC__) || defined(__clang__) |
|
|
|
|
constexpr |
|
|
|
|
#endif |
|
|
|
|
Range1D h{a}; |
|
|
|
|
#if !defined(__GNUC__) || defined(__clang__) |
|
|
|
|
constexpr |
|
|
|
|
#endif |
|
|
|
|
Range2D i{b}; |
|
|
|
|
#if !defined(__GNUC__) || defined(__clang__) |
|
|
|
|
constexpr |
|
|
|
|
#endif |
|
|
|
|
Range3D j{c}; |
|
|
|
|
/* GCC 5.1 had a bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450
|
|
|
|
|
Hopefully this does not reappear. */ |
|
|
|
|
constexpr Range<2, Float> g{b}; |
|
|
|
|
constexpr Range1D h{a}; |
|
|
|
|
constexpr Range2D i{b}; |
|
|
|
|
constexpr Range3D j{c}; |
|
|
|
|
CORRADE_COMPARE(g, e); |
|
|
|
|
CORRADE_COMPARE(h, d); |
|
|
|
|
CORRADE_COMPARE(i, e); |
|
|
|
|
|