Fix "unary minus operator applied to unsigned type, result still unsigned" on MSVC and other stupid warnings

This commit is contained in:
Charles Schlosser
2024-04-12 19:35:04 +00:00
committed by Rasmus Munk Larsen
parent dcdb0233c1
commit 122befe54c
15 changed files with 215 additions and 128 deletions

View File

@@ -22,11 +22,16 @@ namespace Eigen {
namespace test {
template <typename T>
template <typename T, std::enable_if_t<NumTraits<T>::IsSigned, bool> = true>
T negate(const T& x) {
return -x;
}
template <typename T, std::enable_if_t<!NumTraits<T>::IsSigned, bool> = true>
T negate(const T& x) {
return T(0) - x;
}
template <typename T>
Map<const Array<unsigned char, sizeof(T), 1> > bits(const T& x) {
return Map<const Array<unsigned char, sizeof(T), 1> >(reinterpret_cast<const unsigned char*>(&x));