Skip to content

Commit 9a8a3fb

Browse files
committed
Big 3
1 parent bf0cb21 commit 9a8a3fb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

07_SimpleCppApp/main.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <iostream>
2+
#include <cstdlib>
23
#include <cstdint>
34

45
int32_t f(int32_t x)
@@ -10,6 +11,21 @@ class FunctionPreCacher
1011
{
1112
public:
1213
FunctionPreCacher() = default;
14+
FunctionPreCacher(const FunctionPreCacher& other)
15+
{
16+
x = other.x;
17+
count = other.count;
18+
function = other.function;
19+
20+
if (other.values)
21+
{
22+
values = new int32_t[other.count];
23+
if (values)
24+
{
25+
std::memcpy(values, other.values, sizeof(int32_t) * other.count);
26+
}
27+
}
28+
}
1329
FunctionPreCacher(int32_t x, uint32_t count, int32_t(*function)(int32_t))
1430
{
1531
Setup(x, count, function);
@@ -19,6 +35,17 @@ class FunctionPreCacher
1935
Release();
2036
}
2137

38+
FunctionPreCacher& operator=(const FunctionPreCacher& other)
39+
{
40+
if (this != &other)
41+
{
42+
this->~FunctionPreCacher();
43+
this->FunctionPreCacher::FunctionPreCacher(other);
44+
}
45+
46+
return *this;
47+
}
48+
2249
void Setup(int32_t x, uint32_t count, int32_t(*function)(int32_t))
2350
{
2451
if (!values)

0 commit comments

Comments
 (0)