Skip to content

Commit

Permalink
Two little fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jun 26, 2024
1 parent cc4e335 commit 15f6ec2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions include/openPMD/auxiliary/DerefDynamicCast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <optional>
#include <stdexcept>
#include <typeinfo>

namespace openPMD
{
Expand Down Expand Up @@ -64,10 +65,17 @@ namespace auxiliary
inline std::optional<New_Type *>
dynamic_cast_optional(Old_Type *ptr) noexcept
{
auto const tmp_ptr = dynamic_cast<New_Type *>(ptr);
if (tmp_ptr == nullptr)
try
{
auto const tmp_ptr = dynamic_cast<New_Type *>(ptr);
if (tmp_ptr == nullptr)
return std::nullopt;
return {tmp_ptr};
}
catch (std::bad_cast const &)
{
return std::nullopt;
return {tmp_ptr};
}
}

} // namespace auxiliary
Expand Down
2 changes: 1 addition & 1 deletion src/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ namespace
{
for (auto [unit, exponent] : udim)
{
*(it + static_cast<uint8_t>(unit)) = exponent;
it[static_cast<uint8_t>(unit)] = exponent;
}
}
} // namespace
Expand Down

0 comments on commit 15f6ec2

Please sign in to comment.