Console Library
4.7.0
A header-only library that makes C++ simple
Loading...
Searching...
No Matches
literals.h
Go to the documentation of this file.
1
10
11
/*
12
Copyright (c) 2026 MrXie1109
13
14
Permission is hereby granted, free of charge, to any person obtaining a copy
15
of this software and associated documentation files (the "Software"), to deal
16
in the Software without restriction, including without limitation the rights
17
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
copies of the Software, and to permit persons to whom the Software is
19
furnished to do so, subject to the following conditions:
20
21
The above copyright notice and this permission notice shall be included in all
22
copies or substantial portions of the Software.
23
24
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
SOFTWARE.
31
*/
32
33
#pragma once
34
#include "
strpp.h
"
35
#include "
time.h
"
36
42
namespace
console
43
{
44
namespace
literals
45
{
46
// ---------------------------- 时间字面量(整数版本)----------------------------
52
Time
operator
""
_ns(
unsigned
long
long
ns)
53
{
54
return
Time
(ns);
55
}
56
62
Time
operator
""
_us(
unsigned
long
long
us) {
return
Time
(us * 1e3); }
63
69
Time
operator
""
_ms(
unsigned
long
long
ms) {
return
Time
(ms * 1e6); }
70
76
Time
operator
""
_s(
unsigned
long
long
s) {
return
Time
(s * 1e9); }
77
83
Time
operator
""
_min(
unsigned
long
long
min
) {
return
Time
(
min
* 6e10); }
84
90
Time
operator
""
_hr(
unsigned
long
long
hr) {
return
Time
(hr * 3.6e12); }
91
92
// ---------------------------- 时间字面量(浮点数版本)----------------------------
98
Time
operator
""
_ns(
long
double
ns) {
return
Time
(ns); }
99
105
Time
operator
""
_us(
long
double
us) {
return
Time
(us * 1e3); }
106
112
Time
operator
""
_ms(
long
double
ms) {
return
Time
(ms * 1e6); }
113
119
Time
operator
""
_s(
long
double
s) {
return
Time
(s * 1e9); }
120
126
Time
operator
""
_min(
long
double
min
) {
return
Time
(
min
* 6e10); }
127
133
Time
operator
""
_hr(
long
double
hr) {
return
Time
(hr * 3.6e12); }
134
135
// ---------------------------- 格式化字符串字面量 ----------------------------
143
f_string
operator
""
_f(
const
char
*str,
size_t
) {
return
str; }
144
}
145
}
console::Time
表示以纳秒为单位的时间量,支持单位转换、算术运算和自动选择合适的输出单位。
Definition
time.h:52
console::f_string
格式化字符串类,支持使用 % 运算符进行占位符 {} 替换。
Definition
strpp.h:302
console::min
T min(const MultiArray< T, Dims... > &a)
求最小值。
Definition
multiarray.h:1551
console::literals
包含自定义字面量运算符的命名空间。
console
本库所有组件所在的顶层命名空间。
strpp.h
提供字符串处理工具函数和格式化类。
time.h
提供时间度量、计时、休眠和日期时间格式化功能。
console
literals.h
Generated on
for Console Library by
1.16.1