Browse Source

Adapt to removal of CORRADE_MSVC2019_COMPATIBILITY.

Here both cases were related to /permissive- and not to MSVC 2019 bugs,
so I just changed them to rely on the new CORRADE_MSVC_COMPATIBILITY
define.
pull/539/head
Vladimír Vondruš 4 years ago
parent
commit
efcdfc1221
  1. 33
      src/Magnum/Animation/Player.h
  2. 2
      src/Magnum/MeshTools/GenerateNormals.cpp

33
src/Magnum/Animation/Player.h

@ -387,24 +387,23 @@ template<class T, class K
* and you have to ensure that it's kept in scope for the whole
* lifetime of the @ref Player instance.
*/
#ifndef CORRADE_MSVC2019_COMPATIBILITY
#ifndef CORRADE_MSVC_COMPATIBILITY
template<class V, class R> Player<T, K>& add(const Track<K, V, R>& track, R& destination) {
return add(TrackView<const K, const V, R>{track}, destination);
}
#else
/* MSVC 2015 and 2017 is clueless when it comes to trying to deduce the
template parameters (C2893: Failed to specialize function template).
MSVC 2019 works with /permissive-, but I can neither detect presence
of the flag nor force it onto users, so I'm treating it the same.
It works when calling add<V, R> explicitly, but that makes the API
hard to use and inconsistent between platforms. The only possible
workaround is to make add() take *anything*, casting it to proper
TrackView type and then calling add() with explicit template
parameters. This also neatly resolves the Track/TrackView overload,
as the static_cast is either a no-op or it invokes the conversion
operator on Track. The original code also reportedly makes the
Intellisense freezing like hell and adding this overload fixes the
freezes. Three birds with one stone. */
MSVC 2019+ works with /permissive-. It works when calling add<V, R>
explicitly, but that makes the API hard to use and inconsistent
between platforms. The only possible workaround is to make add()
take *anything*, casting it to proper TrackView type and then
calling add() with explicit template parameters. This also neatly
resolves the Track/TrackView overload, as the static_cast is either
a no-op or it invokes the conversion operator on Track. The original
code also reportedly makes the Intellisense freezing like hell and
adding this overload fixes the freezes. Three birds with one
stone. */
template<class Track, class R> Player<T, K>& add(const Track& track, R& destination) {
return add<typename Track::ValueType, R>(static_cast<const TrackView<const K, const typename Track::ValueType, R>&>(track), destination);
}
@ -448,7 +447,7 @@ template<class T, class K
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class V, class R> Player<T, K>& addWithCallback(const Track<K, V, R>& track, void(*callback)(K, const R&, void*), void* userData = nullptr);
#elif !defined(CORRADE_MSVC2019_COMPATIBILITY) /* See above why */
#elif !defined(CORRADE_MSVC_COMPATIBILITY) /* See above why */
template<class V, class R, class Callback> Player<T, K>& addWithCallback(const Track<K, V, R>& track, Callback callback, void* userData = nullptr) {
return addWithCallback(TrackView<const K, const V, R>{track}, callback, userData);
}
@ -487,7 +486,7 @@ template<class T, class K
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class V, class R, class U> Player<T, K>& addWithCallback(const Track<K, V, R>& track, void(*callback)(K, const R&, U&), U& userData);
#elif !defined(CORRADE_MSVC2019_COMPATIBILITY) /* See above why */
#elif !defined(CORRADE_MSVC_COMPATIBILITY) /* See above why */
template<class V, class R, class U, class Callback> Player<T, K>& addWithCallback(const Track<K, V, R>& track, Callback callback, U& userData) {
return addWithCallback(TrackView<const K, const V, R>{track}, callback, userData);
}
@ -532,7 +531,7 @@ template<class T, class K
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class V, class R> Player<T, K>& addWithCallbackOnChange(const Track<K, V, R>& track, void(*callback)(K, const R&, void*), R& destination, void* userData = nullptr);
#elif !defined(CORRADE_MSVC2019_COMPATIBILITY) /* See above why */
#elif !defined(CORRADE_MSVC_COMPATIBILITY) /* See above why */
template<class V, class R, class Callback> Player<T, K>& addWithCallbackOnChange(const Track<K, V, R>& track, Callback callback, R& destination, void* userData = nullptr) {
return addWithCallbackOnChange(TrackView<const K, const V, R>{track}, callback, destination, userData);
}
@ -571,7 +570,7 @@ template<class T, class K
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class V, class R, class U> Player<T, K>& addWithCallbackOnChange(const Track<K, V, R>& track, void(*callback)(K, const R&, void*), R& destination, U& userData);
#elif !defined(CORRADE_MSVC2019_COMPATIBILITY) /* See above why */
#elif !defined(CORRADE_MSVC_COMPATIBILITY) /* See above why */
template<class V, class R, class U, class Callback> Player<T, K>& addWithCallbackOnChange(const Track<K, V, R>& track, Callback callback, R& destination, U& userData) {
return addWithCallbackOnChange(TrackView<const K, const V, R>{track}, callback, destination, userData);
}
@ -623,7 +622,7 @@ template<class T, class K
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class V, class R> Player<T, K>& addRawCallback(const Track<K, V, R>& track, void(*callback)(const TrackViewStorage<const K>&, K, std::size_t&, void*, void(*)(), void*), void* destination, void(*userCallback)(), void* userData);
#elif !defined(CORRADE_MSVC2019_COMPATIBILITY) /* See above why */
#elif !defined(CORRADE_MSVC_COMPATIBILITY) /* See above why */
template<class V, class R, class Callback> Player<T, K>& addRawCallback(const Track<K, V, R>& track, Callback callback, void* destination, void(*userCallback)(), void* userData) {
return addRawCallback(TrackView<const K, const V, R>{track}, callback, destination, userCallback, userData);
}

2
src/Magnum/MeshTools/GenerateNormals.cpp

@ -90,7 +90,7 @@ std::pair<std::vector<UnsignedInt>, std::vector<Vector3>> generateFlatNormals(co
namespace {
#if defined(CORRADE_MSVC2019_COMPATIBILITY) && !defined(CORRADE_MSVC2017_COMPATIBILITY)
#if defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_MSVC_COMPATIBILITY) && _MSC_VER >= 1920 && _MSC_VER < 1930
/* When using /permissive- with MSVC2019, using namespace inside the function
below FOR SOME REASON gets lost when instantiating the template. That's
stupid but what can we do -- the only way to work around that is to move it

Loading…
Cancel
Save