forked from DragonFive/cpp11
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp11_10_uDefineLite.cpp
More file actions
39 lines (32 loc) · 840 Bytes
/
cpp11_10_uDefineLite.cpp
File metadata and controls
39 lines (32 loc) · 840 Bytes
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
/*************************************************************************
> File Name: cpp11_10_uDefineLite.cpp
> Author: DragonFive
> Mail: [email protected]
> Created Time: 2016年07月24日 星期日 16时02分04秒
************************************************************************/
#include <iostream>
using namespace std;
std::size_t operator"" _len(char const *,std::size_t size)
{
return size;
}
class Inch {
public:
Inch() : Inch(0) { }
Inch(double value_) : value(value_) { }
double toCentimeter()const
{
return value*2.54;
}
private:
double value = 0;
};
Inch operator "" _inch(long double arg) {
return Inch(arg);
}
int main() {
cout << (1.0_inch).toCentimeter() << " centimeter" << endl;
cout<<"hehe"s<<endl;
cout<<"haha"_len<<endl;
return 0;
}