From 43806c9a9cc1ca8c38a3e07f5313150b99a6bbdf Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 17:34:08 +0000 Subject: [PATCH] Fixed missing copy constructor. --- test/test_vector.cpp | 11 +++++++++++ vector.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/test/test_vector.cpp b/test/test_vector.cpp index d5feb40a..cbe94355 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -139,6 +139,17 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_constructor) + { + Data data(initial_data.begin(), initial_data.end()); + Data data2(data); + CHECK(data2 == data); + + data2[2] = -1; + CHECK(data2 != data); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/vector.h b/vector.h index 9043e874..77fdfb4c 100644 --- a/vector.h +++ b/vector.h @@ -103,6 +103,15 @@ namespace etl ivector::assign(first, last); } + //************************************************************************* + /// Copy constructor. + //************************************************************************* + vector(const vector& other) + : ivector(reinterpret_cast(&buffer), MAX_SIZE) + { + ivector::assign(other.begin(), other.end()); + } + //************************************************************************* /// Assignment operator. //*************************************************************************