|
|
@@ -10,20 +10,26 @@
|
|
|
class scoped_buffer_capture_t {
|
|
|
public:
|
|
|
scoped_buffer_capture_t(std::ostream & stream)
|
|
|
- : sbuf(stream.rdbuf())
|
|
|
- , out(stream) {
|
|
|
- out.rdbuf(buffer.rdbuf());
|
|
|
+ : buffer()
|
|
|
+ , sbuf(stream.rdbuf())
|
|
|
+ , out(&stream) {
|
|
|
+ out->rdbuf(buffer.rdbuf());
|
|
|
}
|
|
|
|
|
|
~scoped_buffer_capture_t() {
|
|
|
- out.rdbuf(sbuf);
|
|
|
+ out->rdbuf(sbuf);
|
|
|
}
|
|
|
|
|
|
+ scoped_buffer_capture_t(scoped_buffer_capture_t const &) = delete;
|
|
|
+ scoped_buffer_capture_t & operator=(scoped_buffer_capture_t const &) = delete;
|
|
|
+ scoped_buffer_capture_t(scoped_buffer_capture_t &&) = delete;
|
|
|
+ scoped_buffer_capture_t & operator=(scoped_buffer_capture_t &&) = delete;
|
|
|
+
|
|
|
std::string str() const { return buffer.str(); }
|
|
|
private:
|
|
|
- std::stringstream buffer{};
|
|
|
+ std::stringstream buffer;
|
|
|
std::streambuf * sbuf;
|
|
|
- std::ostream & out;
|
|
|
+ std::ostream * out;
|
|
|
};
|
|
|
|
|
|
#define capture_stdout() scoped_buffer_capture_t cap_cout(std::cout)
|