12 #ifndef HPP_UTIL_EXCEPTION_FACTORY_HH 13 # define HPP_UTIL_EXCEPTION_FACTORY_HH 17 # include <hpp/util/config.hh> 22 struct ThrowException {};
24 template <
typename exception>
struct ExceptionFactory;
27 template <
typename exception,
typename In>
28 struct conditional_insertion_operator {
29 typedef ExceptionFactory<exception>& type;
31 static inline type run(ExceptionFactory<exception>& be,
const In& t) { be.ss << t;
return be; }
46 template <
typename exception>
51 template <
typename T>
inline 52 typename internal::conditional_insertion_operator<exception, T>::type
54 return internal::conditional_insertion_operator<exception, T>::run (*
this, t);
63 template <
typename exception>
64 struct conditional_insertion_operator<exception, ThrowException> {
65 typedef exception type;
80 # define HPP_THROW(TYPE, MSG) \ 81 throw ::hpp::ExceptionFactory<TYPE>() << MSG << ::hpp::ThrowException() 87 # define HPP_THROW_WITH_LINEINFO(TYPE, MSG) \ 88 HPP_THROW(TYPE,MSG << " at " << __FILE__ << ":" << __LINE__) Definition: assertion.hh:24
Class to ease exception creation.
Definition: exception-factory.hh:47
HPP_UTIL_DLLAPI std::ostream & operator<<(std::ostream &o, const Exception &exception)
Override operator<< to handle exception display.
Definition: exception.cc:75
std::stringstream ss
Definition: exception-factory.hh:49