-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser-defined.literals.cpp
More file actions
executable file
·45 lines (37 loc) · 1.05 KB
/
user-defined.literals.cpp
File metadata and controls
executable file
·45 lines (37 loc) · 1.05 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
/*
* =====================================================================================
*
* Filename: user-defined.literals.cpp
*
* Description:
*
* Version: 1.0
* Created: 03/21/2019 14:23:37
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:
*
* =====================================================================================
*/
#include <iostream>
typedef long double ull;
ull operator"" _s(ull x) { return x; }
ull operator"" _m(ull x) { return x/60; }
ull operator"" _h(ull x) { return x/3600; }
ull operator"" _d(ull x) { return x/(3600 * 24); }
size_t operator"" _len(char const * str, size_t size) {
return size;
}
int main(void) {
float second = 300.0_s;
float minit = 300.0_m;
float hour = 300.0_h;
float day = 300.0_d;
printf("300(second)=%.4f(s),=%.4f(m),=%.4f(h),=%.4f(d)\n",
second, minit, hour, day);
//printf(R"x(length of "abcdef"=)x");
printf("length of \"abcdef\"=%ld\n", "abcdef"_len );
return 0;
}