File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 11#include < iostream>
2+ #include < cstdlib>
23#include < cstdint>
34
45int32_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)
You can’t perform that action at this time.
0 commit comments