diff --git a/SConstruct b/SConstruct index 2f851b0..cb82381 100644 --- a/SConstruct +++ b/SConstruct @@ -4,5 +4,7 @@ env = DefaultEnvironment(tools=['default', 'compilation_db']) env.CompilationDatabase() +env.Append(CCFLAGS=["-Wall", "-Wextra", "-Werror", "-pedantic"]) + # Build the output program Program('vector.out', Glob('*.cpp')) diff --git a/Vector.h b/Vector.h index 3de0eab..998127f 100644 --- a/Vector.h +++ b/Vector.h @@ -25,7 +25,7 @@ class Vector { } // Move Constructor using the copy-and-swap-idiom - Vector(Vector &&other) : data((T *)::operator new(capacity * sizeof(T))) { + Vector(Vector &&other) : data(nullptr) { swap(*this, other); } @@ -160,9 +160,9 @@ class Vector { } private: - T *data; - unsigned int element_count; unsigned int capacity; + unsigned int element_count; + T *data; bool is_using_excessive_memory() { return 10 + element_count * 2 < capacity;