mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Suppress bad deprecation warnings in MSVC
The Microsoft compiler has this annoying and stupid behavior where if you have a generic templated method/function and that method is instantiated with a deprecated class, then the compiler will issue a C4996 warning even if the calling code is suppressing that warning (because, for example, you are implementing other deprecated code and the use is correct). There is no way around this other than suppressing the warnings for all uses of the templated method.
This commit is contained in:
parent
a3f23a03b6
commit
c689a68c5c
@ -84,7 +84,18 @@ public:
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT ArrayHandleType Cast() const
|
||||
{
|
||||
// MSVC will issue deprecation warnings if this templated method is instantiated with
|
||||
// a deprecated class here even if the method is called from a section of code where
|
||||
// deprecation warnings are suppressed. This is annoying behavior since this templated
|
||||
// method has no control over what class it is used from. To get around it, we have to
|
||||
// suppress all deprecation warnings here.
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
#endif
|
||||
return internal::variant::Cast<ArrayHandleType>(this->ArrayContainer.get());
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
}
|
||||
|
||||
/// \brief Call a functor using the underlying array type.
|
||||
|
@ -211,6 +211,14 @@ struct VTKM_ALWAYS_EXPORT Caster<T, vtkm::cont::StorageTagVirtual>
|
||||
}
|
||||
};
|
||||
|
||||
// MSVC will issue deprecation warnings here if this template is instantiated with
|
||||
// a deprecated class even if the template is used from a section of code where
|
||||
// deprecation warnings are suppressed. This is annoying behavior since this template
|
||||
// has no control over what class it is used with. To get around it, we have to
|
||||
// suppress all deprecation warnings here.
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
#endif
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT ArrayHandleType Cast(const VariantArrayHandleContainerBase* container)
|
||||
{ //container could be nullptr
|
||||
@ -220,6 +228,9 @@ VTKM_CONT ArrayHandleType Cast(const VariantArrayHandleContainerBase* container)
|
||||
auto ret = Caster<Type, Storage>{}(container);
|
||||
return ArrayHandleType(std::move(ret));
|
||||
}
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
|
||||
struct ForceCastToVirtual
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifndef vtk_m_internal_FunctionInterface_h
|
||||
#define vtk_m_internal_FunctionInterface_h
|
||||
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <vtkm/internal/FunctionInterfaceDetailPre.h>
|
||||
@ -237,8 +238,19 @@ VTKM_EXEC_CONT auto ParameterGet(const FunctionInterface<FunctionSignature>& fIn
|
||||
template <typename R, typename... Args>
|
||||
FunctionInterface<R(Args...)> make_FunctionInterface(const Args&... args)
|
||||
{
|
||||
// MSVC will issue deprecation warnings if this templated method is instantiated with
|
||||
// a deprecated class here even if the method is called from a section of code where
|
||||
// deprecation warnings are suppressed. This is annoying behavior since this templated
|
||||
// method has no control over what class it is used from. To get around it, we have to
|
||||
// suppress all deprecation warnings here.
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
#endif
|
||||
detail::ParameterContainer<R(Args...)> container = { args... };
|
||||
return FunctionInterface<R(Args...)>{ container };
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::internal
|
||||
|
Loading…
Reference in New Issue
Block a user