Skip to content

Commit 5f9704c

Browse files
Владимир СеверовВладимир Северов
authored andcommitted
17.04.04 16:08 - Some fixes
1 parent bd39266 commit 5f9704c

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

M2-LW-10/M2-LW-10/Array.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Array {
4444
// User constructor
4545
Array(T data[N])
4646
{
47-
memcpy(data_, data, N * sizeof(value_type));
47+
std::copy(data, data + N, data_);
4848
}
4949

5050
// User constructor
@@ -169,23 +169,13 @@ class Array {
169169
{
170170
std::swap(data_, other.data_);
171171
}
172-
173-
// Friend functions
174-
template<class T, std::size_t N>
175-
friend bool operator==(Array<T, N>& lhs, Array<T, N>& rhs);
176-
177-
template<class T, std::size_t N>
178-
friend bool operator<(Array<T, N>& lhs, Array<T, N>& rhs);
179-
180-
template<class T, std::size_t N>
181-
friend bool operator<=(Array<T, N>& lhs, Array<T, N>& rhs);
182172
};
183173

184174
template<class T, std::size_t N>
185175
bool operator==(Array<T, N>& lhs, Array<T, N>& rhs)
186176
{
187177
for (size_t i = 0; i < N; i++) {
188-
if (lhs.data_[i] != rhs.data_[i]) {
178+
if (lhs[i] != rhs[i]) {
189179
return false;
190180
}
191181
}
@@ -202,7 +192,7 @@ template<class T, std::size_t N>
202192
bool operator<(Array<T, N>& lhs, Array<T, N>& rhs)
203193
{
204194
for (size_t i = 0; i < N; i++) {
205-
if (lhs.data_[i] >= rhs.data_[i]) {
195+
if (lhs[i] >= rhs[i]) {
206196
return false;
207197
}
208198
}
@@ -213,7 +203,7 @@ template<class T, std::size_t N>
213203
bool operator<=(Array<T, N>& lhs, Array<T, N>& rhs)
214204
{
215205
for (size_t i = 0; i < N; i++) {
216-
if (lhs.data_[i] > rhs.data_[i]) {
206+
if (lhs[i] > rhs[i]) {
217207
return false;
218208
}
219209
}

0 commit comments

Comments
 (0)