diff --git a/FileIO/MPI_IO/NodePartitionedMeshReader.cpp b/FileIO/MPI_IO/NodePartitionedMeshReader.cpp index 8bca8f1fcd412f2688a15aa6d1e2305895311934..f600fe580b1cdaf22689388b12eba58d896954a0 100644 --- a/FileIO/MPI_IO/NodePartitionedMeshReader.cpp +++ b/FileIO/MPI_IO/NodePartitionedMeshReader.cpp @@ -28,6 +28,19 @@ #include "MeshLib/Elements/Tet.h" #include "MeshLib/Elements/Tri.h" +// Check if the value can by converted to given type without overflow. +template <typename VALUE, typename TYPE> +bool +is_safely_convertable(VALUE const& value) +{ + bool const result = value <= std::numeric_limits<TYPE>::max(); + if (!result) { + ERR("The value %d is too large for conversion.", value); + ERR("Maximum available size is %d.", std::numeric_limits<TYPE>::max()); + } + return result; +} + namespace FileIO {