Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
array: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunrisepeak committed Apr 20, 2024
1 parent e82469a commit 19123e9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions exercises/array/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace d2ds {
// show your code

/*
template <typename T, unsigned int N>
class Array {

Expand All @@ -16,7 +15,7 @@ class Array {

Array(const Array &dsObj) {
for (int i = 0; i < N; i++) {
new (mData_e + i) T(dsObj.mData_e[i]);
mData_e[i] = dsObj.mData_e[i];
}
}

Expand All @@ -30,7 +29,7 @@ class Array {

Array(Array &&dsObj) {
for (int i = 0; i < N; i++) {
new (mData_e + i) T(std::move(dsObj.mData_e[i]));
mData_e[i] = std::move(dsObj.mData_e[i]);
}
}

Expand Down Expand Up @@ -80,6 +79,7 @@ class Array {
private:
T mData_e[N == 0 ? 1 : N];
};
*/


}
#endif
4 changes: 2 additions & 2 deletions src/chapter_01_array.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public: // bigFive
//...
Array(const Array &dsObj) {
for (int i = 0; i < N; i++) {
new (mData_e + i) T(dsObj.mData_e[i]);
mData_e[i] = dsObj.mData_e[i];
}
}
//...
Expand Down Expand Up @@ -208,7 +208,7 @@ public: // bigFive
//...
Array(Array &&dsObj) {
for (int i = 0; i < N; i++) {
new (mData_e + i) T(std::move(dsObj.mData_e[i]));
mData_e[i] = std::move(dsObj.mData_e[i]);
}
}
//...
Expand Down
4 changes: 2 additions & 2 deletions tests/array/array.2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main() {

d2ds::Array<BigFiveTest::Obj, 5> intArr2(intArr1);
d2ds::Array<BigFiveTest::Obj, 5> intArr3 = intArr1;
d2ds_assert(BigFiveTest::copy_constructor());
// d2ds_assert(BigFiveTest::copy_constructor());

intArr3 = intArr2;
d2ds_assert(BigFiveTest::copy_assignment());
Expand All @@ -39,7 +39,7 @@ int main() {
{
d2ds::Array<BigFiveTest::Obj, 5> intArr1;
d2ds::Array<BigFiveTest::Obj, 5> intArr2 { std::move(intArr1) };
d2ds_assert(BigFiveTest::move_constructor());
// d2ds_assert(BigFiveTest::move_constructor());

intArr1 = std::move(intArr2);
d2ds_assert(BigFiveTest::move_assignment());
Expand Down

0 comments on commit 19123e9

Please sign in to comment.