cheshirekow  v0.1.0
exception_stream.hpp
Go to the documentation of this file.
1 #ifndef MPBLOCKS_UTIL_EXCEPTION_STREAM_HPP_
2 #define MPBLOCKS_UTIL_EXCEPTION_STREAM_HPP_
3 
4 #include <exception>
5 #include <sstream>
6 
7 namespace mpblocks {
8 namespace utility {
9 
11 
19 template <typename Exception_t>
20 class ExceptionStream : public std::stringstream {
21  public:
22  ~ExceptionStream() { throw Exception_t(str().c_str()); }
23 
24  std::ostream& operator()() { return *this; }
25 };
26 
28 
29 } // namespace utility
30 } // namespace mpblocks
31 
32 #endif // MPBLOCKS_UTIL_EXCEPTION_STREAM_HPP_
ExceptionStream< std::runtime_error > ex
const Char8_t * str(const Char8_t *s1, const Char8_t *s2)
used to simplify the process of generating an exception message