acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
auto_ptr_array.h
1#pragma once
2
3
4#include "acme/platform/_referencing_debugging.h"
5
6
7template < typename POINTER_TYPE >
8class auto_ptr_array :
9 public pointer_array_process < comparable_array < POINTER_TYPE * >, POINTER_TYPE >
10{
11public:
12
13
14 using BASE_ARRAY = pointer_array_process < comparable_array < POINTER_TYPE * >, POINTER_TYPE >;
15
16 using pointer_array_process < comparable_array < POINTER_TYPE * >, POINTER_TYPE >::pointer_array_process;
17
18
19 auto_ptr_array() { }
20 auto_ptr_array(auto_ptr_array && array) : pointer_array_process < comparable_array < POINTER_TYPE * >, POINTER_TYPE >(::transfer(array)) { }
21 ~auto_ptr_array() override { this->erase_all(); }
22
23
24 POINTER_TYPE & object_at(::collection::index i) { return *this->element_at(i); }
25 const POINTER_TYPE & object_at(::collection::index i) const { return *this->element_at(i); }
26
27
28 void set_size(::collection::count c)
29 {
30
31 auto i = this->size();
32
33 BASE_ARRAY::set_size(c);
34
35 for(; i < c; i++)
36 {
37
38 this->element_at(i) = ___new POINTER_TYPE;
39
40 }
41
42 }
43
44
45 ::collection::index erase_at(::collection::index i)
46 {
47
48 ::acme::del(this->element_at(i));
49
50 return BASE_ARRAY::erase_at(i);
51
52 }
53
54
55 ::collection::count erase_all()
56 {
57
58 for(auto & p : *this)
59 {
60
61 ::acme::del(p);
62
63 }
64
65 return BASE_ARRAY::erase_all();
66
67 }
68
69
70};
71
72
73namespace acme
74{
75
76
77 template < class TDST, class TSRC >
78 ::collection::count copy(auto_ptr_array < TDST >& dsta, const auto_ptr_array < TSRC >& srca)
79 {
80
81 dsta.erase_all();
82
83 dsta.set_size(srca.get_size());
84
85 for (::i32 i = 0; i < srca.get_size(); i++)
86 {
87
88 dsta[i] = ___new TDST(*srca[i]);
89
90 }
91
92 return dsta.get_size();
93
94 }
95
96
97} // namespace acme
98
99
100
include "aura/graphics/image/context.h"
Definition aaaa__defer.h:32