From d60e55603fbdea0a87632e2a1d67dfaa59cb3076 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Mon, 1 Nov 2021 10:55:48 +0100
Subject: [PATCH] [MeL/VTK] Move one of if-cnds in static assert.

---
 MeshLib/MeshGenerators/VtkMeshConverter.cpp | 38 ++++++---------------
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/MeshLib/MeshGenerators/VtkMeshConverter.cpp b/MeshLib/MeshGenerators/VtkMeshConverter.cpp
index 4529ac10b11..cd65fee3e46 100644
--- a/MeshLib/MeshGenerators/VtkMeshConverter.cpp
+++ b/MeshLib/MeshGenerators/VtkMeshConverter.cpp
@@ -336,8 +336,10 @@ void VtkMeshConverter::convertArray(vtkDataArray& array,
         return;
     }
 
-    if constexpr (sizeof(std::int64_t) == sizeof(long long) &&
-                  sizeof(long long) == sizeof(long))
+    // Ensure, vtkTypeInt64Array and vtkLongLongArray are using the same type.
+    static_assert(sizeof(std::int64_t) == sizeof(long long));
+
+    if constexpr (sizeof(long long) == sizeof(long))
     {
         // This also covers the vtkTypeInt64Array type, which is derived from
         // the vtkLongLongArray type.
@@ -348,8 +350,7 @@ void VtkMeshConverter::convertArray(vtkDataArray& array,
             return;
         }
     }
-    else if constexpr (sizeof(std::int64_t) == sizeof(long long) &&
-                       sizeof(long long) != sizeof(long))
+    else
     {
         // This also covers the vtkTypeInt64Array type, which is derived from
         // the vtkLongLongArray type.
@@ -360,15 +361,6 @@ void VtkMeshConverter::convertArray(vtkDataArray& array,
             return;
         }
     }
-    else
-    {
-        OGS_FATAL(
-            "Array '{:s}' in VTU file uses unsupported data type '{:s}' not "
-            "convertible to long or long long. Size of long is {:d}, size of "
-            "long long is {:d}.",
-            array.GetName(), array.GetDataTypeAsString(), sizeof(long),
-            sizeof(long long));
-    }
 
     // This also covers the vtkTypeUInt8Array type, which is derived from the
     // vtkUnsignedCharArray type.
@@ -428,8 +420,11 @@ void VtkMeshConverter::convertArray(vtkDataArray& array,
         return;
     }
 
-    if constexpr (sizeof(std::uint64_t) == sizeof(unsigned long long) &&
-                  sizeof(unsigned long long) == sizeof(unsigned long))
+    // Ensure, vtkTypeUInt64Array and vtkUnsignedLongLongArray are using the
+    // same type.
+    static_assert(sizeof(std::uint64_t) == sizeof(unsigned long long));
+
+    if constexpr (sizeof(unsigned long long) == sizeof(unsigned long))
     {
         // This also covers the vtkTypeUInt64Array type, which is derived from
         // the vtkUnsignedLongLongArray type.
@@ -441,8 +436,7 @@ void VtkMeshConverter::convertArray(vtkDataArray& array,
             return;
         }
     }
-    else if constexpr (sizeof(std::uint64_t) == sizeof(unsigned long long) &&
-                       sizeof(unsigned long long) != sizeof(unsigned long))
+    else
     {
         // This also covers the vtkTypeUInt64Array type, which is derived from
         // the vtkUnsignedLongLongArray type.
@@ -453,16 +447,6 @@ void VtkMeshConverter::convertArray(vtkDataArray& array,
             return;
         }
     }
-    else
-    {
-        OGS_FATAL(
-            "Array '{:s}' in VTU file uses unsupported data type '{:s}' "
-            "not convertible to unsigned long or unsigned long long. Size of "
-            "unsigned long is {:d}, size of unsigned long long is {:d}, size "
-            "of std::size_t is {:d}.",
-            array.GetName(), array.GetDataTypeAsString(), sizeof(unsigned long),
-            sizeof(unsigned long long), sizeof(std::size_t));
-    }
 
     WARN(
         "Array '{:s}' in VTU file uses unsupported data type '{:s}' of size "
-- 
GitLab