diff --git a/src/Magnum/Trade/MaterialData.h b/src/Magnum/Trade/MaterialData.h index ecfa2701e..61a737b3d 100644 --- a/src/Magnum/Trade/MaterialData.h +++ b/src/Magnum/Trade/MaterialData.h @@ -2636,7 +2636,17 @@ template constexpr MaterialAttributeData::MaterialAttributeData(const Containers::StringView name, const T& value) noexcept: _data{Implementation::MaterialAttributeTypeFor::type(), (CORRADE_CONSTEXPR_ASSERT(name.size() + sizeof(T) + 2 <= Implementation::MaterialAttributeDataSize, "Trade::MaterialAttributeData: name" << name << "too long, expected at most" << Implementation::MaterialAttributeDataSize - sizeof(T) - 2 << "bytes for" << Implementation::MaterialAttributeTypeFor::type() << "but got" << name.size()), name), value} {} +> constexpr MaterialAttributeData::MaterialAttributeData(const Containers::StringView name, const T& value) noexcept: + _data{Implementation::MaterialAttributeTypeFor::type(), + /* MSVC 2015 complains about "error C2065: 'T': undeclared identifier" + in the lambda inside this macro. Sorry, the assert will be less + useful on that stupid thing. */ + #ifndef CORRADE_MSVC2015_COMPATIBILITY + (CORRADE_CONSTEXPR_ASSERT(name.size() + sizeof(T) + 2 <= Implementation::MaterialAttributeDataSize, "Trade::MaterialAttributeData: name" << name << "too long, expected at most" << Implementation::MaterialAttributeDataSize - sizeof(T) - 2 << "bytes for" << Implementation::MaterialAttributeTypeFor::type() << "but got" << name.size()), name) + #else + (CORRADE_CONSTEXPR_ASSERT(name.size() + sizeof(T) + 2 <= Implementation::MaterialAttributeDataSize, "Trade::MaterialAttributeData: name" << name << "too long, got" << name.size() << "bytes"), name) + #endif + , value} {} /* The 4 extra bytes are for a null byte after both the name and value, a type and a string size */ diff --git a/src/Magnum/Trade/Test/MaterialDataTest.cpp b/src/Magnum/Trade/Test/MaterialDataTest.cpp index 6c6e2bd45..6d9dad15c 100644 --- a/src/Magnum/Trade/Test/MaterialDataTest.cpp +++ b/src/Magnum/Trade/Test/MaterialDataTest.cpp @@ -821,11 +821,18 @@ void MaterialDataTest::constructAttributeTooLarge() { Error redirectError{&out}; MaterialAttributeData{"attributeIsLong", Matrix3x4{}}; /* Constexpr variant has the same assert, but in the header. It should have - the same output. */ + the same output. Except on MSVC 2015, which is a crap thing and gets + lost when encountering T in there, so the assert is less useful. */ /*constexpr*/ MaterialAttributeData{"attributeIsLong"_s, Matrix3x4{}}; + #ifndef CORRADE_MSVC2015_COMPATIBILITY CORRADE_COMPARE(out.str(), "Trade::MaterialAttributeData: name attributeIsLong too long, expected at most 14 bytes for Trade::MaterialAttributeType::Matrix3x4 but got 15\n" "Trade::MaterialAttributeData: name attributeIsLong too long, expected at most 14 bytes for Trade::MaterialAttributeType::Matrix3x4 but got 15\n"); + #else + CORRADE_COMPARE(out.str(), + "Trade::MaterialAttributeData: name attributeIsLong too long, expected at most 14 bytes for Trade::MaterialAttributeType::Matrix3x4 but got 15\n" + "Trade::MaterialAttributeData: name attributeIsLong too long, got 15 bytes\n"); + #endif } void MaterialDataTest::constructAttributeTooLargeString() {