#include <iostream.h>
Public Member Functions | |
scoped_ostream_redirect & | operator= (const scoped_ostream_redirect &)=delete |
scoped_ostream_redirect & | operator= (scoped_ostream_redirect &&)=delete |
scoped_ostream_redirect (std::ostream &costream=std::cout, object pyostream=module::import("sys").attr("stdout")) | |
scoped_ostream_redirect (const scoped_ostream_redirect &)=delete | |
scoped_ostream_redirect (scoped_ostream_redirect &&other)=default | |
~scoped_ostream_redirect () | |
Protected Attributes | |
detail::pythonbuf | buffer |
std::ostream & | costream |
std::streambuf * | old |
This a move-only guard that redirects output.
.. code-block:: cpp
#include <pybind11/iostream.h> ... { py::scoped_ostream_redirect output; std::cout << "Hello, World!"; // Python stdout } // <-- return std::cout to normal
You can explicitly pass the c++ stream and the python object, for example to guard stderr instead.
.. code-block:: cpp
{ py::scoped_ostream_redirect output{std::cerr, py::module::import("sys").attr("stderr")}; std::cerr << "Hello, World!"; }
Definition at line 109 of file iostream.h.
|
inline |
Definition at line 116 of file iostream.h.
|
inline |
Definition at line 123 of file iostream.h.
|
delete |
|
default |
|
delete |
|
delete |
|
protected |
Definition at line 113 of file iostream.h.
|
protected |
Definition at line 112 of file iostream.h.
|
protected |
Definition at line 111 of file iostream.h.