This repository was archived by the owner on Oct 18, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathClassOperatorHandler9Test.expect
More file actions
129 lines (100 loc) · 2.86 KB
/
Copy pathClassOperatorHandler9Test.expect
File metadata and controls
129 lines (100 loc) · 2.86 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#define INSIGHTS_USE_TEMPLATE
#include <vector>
template<typename T>
class MyVector
{
std::vector<T> v;
public:
// MyVector with initial size
MyVector(const std::size_t n)
: v(n)
{
}
// MyVector with initial size and value
MyVector(const std::size_t n, const double initialValue)
: v(n, initialValue)
{
}
// size of underlying container
std::size_t size() const { return v.size(); }
// index operators
T operator[](const std::size_t i) const { return v[i]; }
T& operator[](const std::size_t i) { return v[i]; }
};
/* First instantiated from: ClassOperatorHandler9Test.cpp:34 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
class MyVector<int>
{
std::vector<int, std::allocator<int> > v;
public:
inline MyVector(const std::size_t n)
: v{std::vector<int, std::allocator<int> >(n)}
{
}
inline MyVector(const std::size_t n, const double initialValue)
: v{std::vector<int, std::allocator<int> >(n, static_cast<const int>(initialValue))}
{
}
inline std::size_t size() const
{
return this->v.size();
}
inline int operator[](const std::size_t i) const
{
return this->v.operator[](i);
}
inline int & operator[](const std::size_t i)
{
return this->v.operator[](i);
}
// inline MyVector(MyVector<int> &&) noexcept = default;
// inline ~MyVector() noexcept = default;
};
#endif
using vec_t = MyVector<int>;
MyVector<int> operator+(const MyVector<int> & a, const MyVector<int> & b)
{
vec_t result = MyVector<int>(a.size()) /* NRVO variable */;
for(std::size_t s = 0; s <= a.size(); ++s) {
result.operator[](s) = (a.operator[](s) + b.operator[](s));
}
return MyVector<int>(static_cast<MyVector<int> &&>(result));
}
template<typename T>
MyVector<T> operator*(const MyVector<T>& a, const MyVector<T>& b)
{
MyVector<T> result(a.size());
for(std::size_t s = 0; s <= a.size(); ++s) {
result[s] = a[s] + b[s];
}
return result;
}
/* First instantiated from: ClassOperatorHandler9Test.cpp:70 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
MyVector<int> operator*<int>(const MyVector<int> & a, const MyVector<int> & b)
{
MyVector<int> result = MyVector<int>(a.size()) /* NRVO variable */;
for(std::size_t s = 0; s <= a.size(); ++s) {
result.operator[](s) = (a.operator[](s) + b.operator[](s));
}
return MyVector<int>(static_cast<MyVector<int> &&>(result));
}
#endif
MyVector<int> Foo(const MyVector<int> & a, const MyVector<int> & b)
{
vec_t result = MyVector<int>{a.size()} /* NRVO variable */;
for(std::size_t s = 0; s <= a.size(); ++s) {
result.operator[](s) = (a.operator[](s) + b.operator[](s));
}
return MyVector<int>(static_cast<MyVector<int> &&>(result));
}
int main()
{
vec_t vecA = MyVector<int>(4, 2);
vec_t vecB = MyVector<int>(6, 7);
vec_t res = Foo(vecA, vecB);
operator+(vecA, vecB);
operator*(vecA, vecB);
}