29 #ifndef PIRANHA_EXCEPTIONS_HPP 30 #define PIRANHA_EXCEPTIONS_HPP 40 #include <type_traits> 50 template <
typename Exception>
53 using line_type = uncvref_t<decltype(__LINE__)>;
54 explicit ex_thrower(
const char *file, line_type line,
const char *func) : m_file(file), m_line(line), m_func(func)
57 template <
typename... Args,
typename = enable_if_t<std::is_constructible<Exception, Args &&...>::value>>
58 [[noreturn]]
void operator()(Args &&... args)
const 60 throw Exception(std::forward<Args>(args)...);
62 template <
typename Str>
63 using str_add_t = decltype(std::declval<std::string &>() += std::declval<Str>());
64 template <
typename Str,
typename... Args,
65 typename = enable_if_t<conjunction<std::is_constructible<Exception, std::string, Args &&...>,
66 is_detected<str_add_t, Str &&>>::value>>
67 [[noreturn]]
void operator()(Str &&desc, Args &&... args)
const 69 std::string msg(
"\nfunction: ");
74 msg += std::to_string(m_line);
76 msg += std::forward<Str>(desc);
78 throw Exception(msg, std::forward<Args>(args)...);
81 const line_type m_line;
118 #define piranha_throw(exception_type, ...) \ 119 piranha::ex_thrower<exception_type>(__FILE__, __LINE__, __func__)(__VA_ARGS__) 129 using std::runtime_error::runtime_error;
137 using std::domain_error::domain_error;
Exception for signalling division by zero.
Exception for functionality not implemented or not available on the current platform.