35 #ifndef HPP_UTIL_EXCEPTION_FACTORY_HH
36 #define HPP_UTIL_EXCEPTION_FACTORY_HH
43 struct ThrowException {};
45 template <
typename exception>
46 struct ExceptionFactory;
49 template <
typename exception,
typename In>
50 struct conditional_insertion_operator {
51 typedef ExceptionFactory<exception>& type;
53 static inline type run(ExceptionFactory<exception>& be,
const In& t) {
72 template <
typename exception>
77 inline typename internal::conditional_insertion_operator<exception, T>::type
79 return internal::conditional_insertion_operator<exception, T>::run(*
this,
89 template <
typename exception>
90 struct conditional_insertion_operator<exception, ThrowException> {
91 typedef exception type;
93 static inline type run(ExceptionFactory<exception>& be,
94 const ThrowException&) {
95 return exception(be.ss.str().c_str());
109 #define HPP_THROW(TYPE, MSG) \
110 throw ::hpp::ExceptionFactory<TYPE>() << MSG << ::hpp::ThrowException()
116 #define HPP_THROW_WITH_LINEINFO(TYPE, MSG) \
117 HPP_THROW(TYPE, MSG << " at " << __FILE__ << ":" << __LINE__)