-
Notifications
You must be signed in to change notification settings - Fork 1
/
cppFriendsClangExt.cpp
62 lines (52 loc) · 1.45 KB
/
cppFriendsClangExt.cpp
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
/* gccとclangを比較する */
#define _USE_MATH_DEFINES
#include <cmath>
#include "cppFriendsClang.hpp"
namespace SwitchCase {
double GetAreaOfCircle(double radius) {
return radius * radius * M_PI;
}
double GetAreaOfRectangular(double width, double height) {
return width * height;
}
// ヘロンの公式
double GetAreaOfTriangle(double edge1, double edge2, double edge3) {
double halfSum = edge1 + edge2 + edge3;
halfSum /= 2.0;
double product = halfSum * (halfSum - edge1) * (halfSum - edge2) * (halfSum - edge3);
return std::sqrt(product);
}
}
namespace Devirtualization {
void BaseOutline::Print(std::ostream& os) {
os << "BaseOutline";
return;
}
void DerivedOutline::Print(std::ostream& os) {
os << "DerivedOutline";
return;
}
std::unique_ptr<BaseOutline> CreateBaseOutline(void) {
return std::make_unique<BaseOutline>();
}
std::unique_ptr<BaseOutline> CreateDerivedOutline(void) {
return std::make_unique<DerivedOutline>();
}
}
// LTOで削除する
int UnusedFunction(void) {
return 0;
}
// LTOだと動作が変わる。未定義動作だから仕方ない。
uint32_t ShiftManyFor1(uint32_t src) {
uint32_t i = 1;
return (i << src);
}
/*
Local Variables:
mode: c++
coding: utf-8-dos
tab-width: nil
c-file-style: "stroustrup"
End:
*/