summaryrefslogtreecommitdiffstats
path: root/ue5/array.hpp
diff options
context:
space:
mode:
authormanuel <manuel@nc8430.lan>2009-06-04 16:31:09 +0200
committermanuel <manuel@nc8430.lan>2009-06-04 16:31:09 +0200
commit2c0bf4d7935626ef299f1be3f992b1dfe4c0b19f (patch)
tree881b3ec20c67018ca2d693071960a462adf9cf52 /ue5/array.hpp
parent6e3bff52c888c22d8a76c6ff741785f0463456e4 (diff)
downloadooprog-2c0bf4d7935626ef299f1be3f992b1dfe4c0b19f.tar.gz
ooprog-2c0bf4d7935626ef299f1be3f992b1dfe4c0b19f.tar.bz2
ooprog-2c0bf4d7935626ef299f1be3f992b1dfe4c0b19f.zip
shared_ptr
Diffstat (limited to 'ue5/array.hpp')
-rw-r--r--ue5/array.hpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/ue5/array.hpp b/ue5/array.hpp
index 9c8a7e6..e9adc55 100644
--- a/ue5/array.hpp
+++ b/ue5/array.hpp
@@ -22,21 +22,21 @@ namespace Ti
22 22
23 void fill(const T& u) 23 void fill(const T& u)
24 { 24 {
25 for(size_type i = 0; i < size(); ++i)
26 m_data[i] = u;
27 /* std::fill_n(begin(), size(), u); */ 25 /* std::fill_n(begin(), size(), u); */
26 for(size_type i = 0; i < N; ++i)
27 m_data[i] = u;
28 } 28 }
29 29
30 /* range check not necessary. N must be the same in other */ 30 /* range check not necessary. N must be the same in other */
31 void swap(array<T,N> & other) 31 void swap(array<T,N> & other)
32 { 32 {
33 for(size_type i = 0; i < size(); ++i) 33 /* std::swap_ranges(begin(), end(), other.begin()); */
34 for(size_type i = 0; i < N; ++i)
34 { 35 {
35 T x(m_data[i]); 36 T x(m_data[i]);
36 m_data[i] = other[i]; 37 m_data[i] = other.m_data[i];
37 other[i] = x; 38 other.m_data[i] = x;
38 } 39 }
39 /* std::swap_ranges(begin(), end(), other.begin()); */
40 } 40 }
41 41
42 iterator begin() 42 iterator begin()
@@ -51,12 +51,12 @@ namespace Ti
51 51
52 iterator end() 52 iterator end()
53 { 53 {
54 return m_data + size(); 54 return m_data + N;
55 } 55 }
56 56
57 const_iterator end() const 57 const_iterator end() const
58 { 58 {
59 return m_data + size(); 59 return m_data + N;
60 } 60 }
61 61
62 size_type size() const 62 size_type size() const
@@ -86,14 +86,14 @@ namespace Ti
86 86
87 reference at(size_type n) 87 reference at(size_type n)
88 { 88 {
89 if (n >= size()) 89 if (n >= N)
90 throw std::out_of_range("array::at"); 90 throw std::out_of_range("array::at");
91 return m_data[n]; 91 return m_data[n];
92 } 92 }
93 93
94 const_reference at(size_type n) const 94 const_reference at(size_type n) const
95 { 95 {
96 if (n >= size()) 96 if (n >= N)
97 throw std::out_of_range("array::at"); 97 throw std::out_of_range("array::at");
98 return m_data[n]; 98 return m_data[n];
99 } 99 }
@@ -107,7 +107,7 @@ namespace Ti
107 T m_data[N]; 107 T m_data[N];
108 }; 108 };
109 109
110 /* std::move makes rvalue from rvalue */ 110 /* std::move returns lvalue as rvalue */
111 template<typename T, std::size_t N> 111 template<typename T, std::size_t N>
112 array<T, N>&& make_array() 112 array<T, N>&& make_array()
113 { 113 {