gtsam 4.1.1
gtsam
utilities.h
1#pragma once
2
3namespace gtsam {
12 RedirectCout() : ssBuffer_(), coutBuffer_(std::cout.rdbuf(ssBuffer_.rdbuf())) {}
13
15 std::string str() const {
16 return ssBuffer_.str();
17 }
18
21 std::cout.rdbuf(coutBuffer_);
22 }
23
24private:
25 std::stringstream ssBuffer_;
26 std::streambuf* coutBuffer_;
27};
28
29}
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
For Python str().
Definition: utilities.h:10
~RedirectCout()
destructor – redirect stdout buffer to its original buffer
Definition: utilities.h:20
std::string str() const
return the string
Definition: utilities.h:15
RedirectCout()
constructor – redirect stdout buffer to a stringstream buffer
Definition: utilities.h:12