forked from asaidalaoui/cs371p
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemory.h
39 lines (34 loc) · 807 Bytes
/
Memory.h
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
// --------
// Memory.h
// --------
#ifndef Memory_h
#define Memory_h
template <typename A, typename BI>
BI my_destroy (A& a, BI b, BI e) {
while (b != e) {
--e;
a.destroy(&*e);}
return b;}
template <typename A, typename II, typename BI>
BI my_uninitialized_copy (A& a, II b, II e, BI x) {
BI p = x;
try {
while (b != e) {
a.construct(&*x, *b);
++b;
++x;}}
catch (...) {
my_destroy(a, p, x);
throw;}
return x;}
template <typename A, typename BI, typename U>
void my_uninitialized_fill (A& a, BI b, BI e, const U& v) {
BI p = b;
try {
while (b != e) {
a.construct(&*b, v);
++b;}}
catch (...) {
my_destroy(a, p, b);
throw;}}
#endif // Memory_h