From: David Wells Date: Tue, 13 Aug 2024 21:47:28 +0000 (-0600) Subject: DataOutInterface: remove some reinterpret_casts. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=903ecac32edf73205bccd983c3e11a1fc3a1f1fd;p=dealii.git DataOutInterface: remove some reinterpret_casts. --- diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index a3449bd4b8..2e02fdd8d3 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -8862,33 +8862,29 @@ template void DataOutInterface::set_flags(const FlagType &flags) { - // The price for not writing ten duplicates of this function is some loss in - // type safety. - if (typeid(flags) == typeid(dx_flags)) - dx_flags = *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(ucd_flags)) - ucd_flags = *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(povray_flags)) - povray_flags = *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(eps_flags)) - eps_flags = *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(gmv_flags)) - gmv_flags = *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(hdf5_flags)) - hdf5_flags = *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(tecplot_flags)) - tecplot_flags = - *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(vtk_flags)) - vtk_flags = *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(svg_flags)) - svg_flags = *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(gnuplot_flags)) - gnuplot_flags = - *reinterpret_cast(&flags); - else if (typeid(flags) == typeid(deal_II_intermediate_flags)) - deal_II_intermediate_flags = - *reinterpret_cast(&flags); + if constexpr (std::is_same_v) + dx_flags = flags; + else if constexpr (std::is_same_v) + ucd_flags = flags; + else if constexpr (std::is_same_v) + povray_flags = flags; + else if constexpr (std::is_same_v) + eps_flags = flags; + else if constexpr (std::is_same_v) + gmv_flags = flags; + else if constexpr (std::is_same_v) + hdf5_flags = flags; + else if constexpr (std::is_same_v) + tecplot_flags = flags; + else if constexpr (std::is_same_v) + vtk_flags = flags; + else if constexpr (std::is_same_v) + svg_flags = flags; + else if constexpr (std::is_same_v) + gnuplot_flags = flags; + else if constexpr (std::is_same_v) + deal_II_intermediate_flags = flags; else DEAL_II_NOT_IMPLEMENTED(); }