12 #ifndef HPP_UTIL_EXCEPTION_FACTORY_HH
13 # define HPP_UTIL_EXCEPTION_FACTORY_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;
67 static inline type run(ExceptionFactory<exception>& be,
const ThrowException&) {
return exception(be.ss.str().c_str()); }
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__)