-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasyprint.hpp
More file actions
74 lines (60 loc) · 1.25 KB
/
easyprint.hpp
File metadata and controls
74 lines (60 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @author: 0.382
* @description: 自定义的一些方便输出输出的函数
*/
#pragma once
#ifndef EASY_PRINT_HPP
#define EASY_PRINT_HPP
#include <cstdlib>
#include <iostream>
#include <string_view>
namespace util
{
// 普通打印
template <typename... Args>
void print(Args &&...args);
template <typename T>
void print(T &&value)
{
std::cout << value;
}
template <typename... Args>
void print(Args &&...args)
{
(print(args), ...);
}
template <typename... Args>
void println(Args &&...args)
{
(print(args), ...);
std::cout << std::endl;
}
// 打印一些信息并终止程序
template <typename... Args>
void stop(Args &&...args)
{
println(args...);
std::exit(-1);
}
// 带分隔符的打印
template <typename T, typename... Args>
void sep_print(std::string_view sep, T &&val, Args &&...args);
template <typename T>
void sep_print(std::string_view sep, T &&val)
{
print(val);
}
template <typename T, typename... Args>
void sep_print(std::string_view sep, T &&val, Args &&...args)
{
print(val, sep);
sep_print(sep, args...);
}
template <typename... Args>
void sep_println(std::string_view sep, Args &&...args)
{
sep_print(sep, args...);
std::cout << std::endl;
}
} // namespace util
#endif // EASY_PRINT_HPP