Skip to content
Snippets Groups Projects
Commit aaeb3df4 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Fix type label deduction in VTKWriter

fix #15
parent 029ce0ce
No related branches found
No related tags found
1 merge request!28Issue/15
......@@ -85,6 +85,19 @@ class VTKWriter
template <typename DataType>
struct VTKType
{
inline const static std::string name = [] {
static_assert(std::is_arithmetic_v<DataType>, "invalid data type");
if constexpr (std::is_integral_v<DataType>) {
if constexpr (std::is_unsigned_v<DataType>) {
return "UInt" + std::to_string(sizeof(DataType) * 8);
} else {
return "UInt" + std::to_string(sizeof(DataType) * 8);
}
} else if constexpr (std::is_floating_point_v<DataType>) {
return "Float" + std::to_string(sizeof(DataType) * 8);
}
}();
};
template <typename DataType>
......@@ -360,64 +373,4 @@ class VTKWriter
~VTKWriter() = default;
};
template <>
struct VTKWriter::VTKType<int8_t>
{
inline const static std::string name{"Int8"};
};
template <>
struct VTKWriter::VTKType<uint8_t>
{
inline const static std::string name{"UInt8"};
};
template <>
struct VTKWriter::VTKType<int16_t>
{
inline const static std::string name{"Int16"};
};
template <>
struct VTKWriter::VTKType<uint16_t>
{
inline const static std::string name{"UInt16"};
};
template <>
struct VTKWriter::VTKType<int32_t>
{
inline const static std::string name{"Int32"};
};
template <>
struct VTKWriter::VTKType<uint32_t>
{
inline const static std::string name{"UInt32"};
};
template <>
struct VTKWriter::VTKType<int64_t>
{
inline const static std::string name{"Int64"};
};
template <>
struct VTKWriter::VTKType<uint64_t>
{
inline const static std::string name{"UInt64"};
};
template <>
struct VTKWriter::VTKType<float>
{
inline const static std::string name{"Float32"};
};
template <>
struct VTKWriter::VTKType<double>
{
inline const static std::string name{"Float64"};
};
#endif // VTK_WRITER_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment