灵活的输出控制类,支持链式调用和多种参数。
More...
#include <output.h>
|
| | Output () |
| | 默认构造,输出到 std::cout,分隔符为空格,结尾为换行,并刷新。
|
| | Output (std::ostream &o, const std::string &s, const std::string &e, bool isF) |
| | 自定义构造。
|
| Output & | operator() () |
| | 无参数调用:仅输出结尾符(如换行)。
|
| template<class T> |
| Output & | operator() (const T &t) |
| | 单参数调用:输出该参数后加结尾符。
|
| template<class T, class... Args> |
| Output & | operator() (const T &t, const Args &...args) |
| | 多参数调用:依次输出每个参数,参数之间插入分隔符,最后加结尾符。
|
灵活的输出控制类,支持链式调用和多种参数。
该类允许用户指定分隔符、结尾符和是否立即刷新,并提供 operator() 重载 来接收任意数量的参数进行格式化输出。 默认全局实例 print 的行为类似于 Python 的 print 函数。
使用示例:
Output err(std::cerr,
"",
"\n",
true);
err("Error:", code);
Output()
默认构造,输出到 std::cout,分隔符为空格,结尾为换行,并刷新。
Definition output.h:381
class console::Output print
全局输出对象,模仿 Python 的 print 函数。
◆ Output() [1/2]
| console::Output::Output |
( |
| ) |
|
|
inline |
默认构造,输出到 std::cout,分隔符为空格,结尾为换行,并刷新。
◆ Output() [2/2]
| console::Output::Output |
( |
std::ostream & | o, |
|
|
const std::string & | s, |
|
|
const std::string & | e, |
|
|
bool | isF ) |
|
inline |
自定义构造。
- Parameters
-
| o | 输出流。 |
| s | 参数之间的分隔符。 |
| e | 结尾符。 |
| isF | 输出后是否刷新。 |
◆ operator()() [1/3]
| Output & console::Output::operator() |
( |
| ) |
|
|
inline |
无参数调用:仅输出结尾符(如换行)。
- Returns
- Output& 当前对象引用,支持链式调用。
◆ operator()() [2/3]
template<class T>
| Output & console::Output::operator() |
( |
const T & | t | ) |
|
|
inline |
单参数调用:输出该参数后加结尾符。
- Template Parameters
-
- Parameters
-
- Returns
- Output& 当前对象引用。
◆ operator()() [3/3]
template<class T, class... Args>
| Output & console::Output::operator() |
( |
const T & | t, |
|
|
const Args &... | args ) |
|
inline |
多参数调用:依次输出每个参数,参数之间插入分隔符,最后加结尾符。
- Template Parameters
-
- Parameters
-
- Returns
- Output& 当前对象引用。
The documentation for this class was generated from the following file: