Skip to content

Commit

Permalink
[cpp] Add raise function
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Jul 14, 2024
1 parent f5c3e62 commit 3e13923
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cpp/pffdtd/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@

namespace pffdtd {

template<typename E, typename... Args>
[[noreturn]] auto raise(Args&&... args) -> void {
throw E{std::forward<Args>(args)...};
}

template<typename E, typename... Args>
[[noreturn]] auto raisef(fmt::format_string<Args...> str, Args&&... args)
-> void {
throw E{fmt::format(str, std::forward<Args>(args)...)};
raise<E>(fmt::format(str, std::forward<Args>(args)...));
}

} // namespace pffdtd

0 comments on commit 3e13923

Please sign in to comment.