Enable all warnings and fix a few

This commit is contained in:
karl 2021-03-15 13:50:07 +01:00
parent d1fd4eb017
commit 3365d5986b
2 changed files with 5 additions and 3 deletions

View File

@ -4,5 +4,7 @@
env = DefaultEnvironment(tools=['default', 'compilation_db']) env = DefaultEnvironment(tools=['default', 'compilation_db'])
env.CompilationDatabase() env.CompilationDatabase()
env.Append(CCFLAGS=["-Wall", "-Wextra", "-Werror", "-pedantic"])
# Build the output program # Build the output program
Program('vector.out', Glob('*.cpp')) Program('vector.out', Glob('*.cpp'))

View File

@ -25,7 +25,7 @@ class Vector {
} }
// Move Constructor using the copy-and-swap-idiom // 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); swap(*this, other);
} }
@ -160,9 +160,9 @@ class Vector {
} }
private: private:
T *data;
unsigned int element_count;
unsigned int capacity; unsigned int capacity;
unsigned int element_count;
T *data;
bool is_using_excessive_memory() { bool is_using_excessive_memory() {
return 10 + element_count * 2 < capacity; return 10 + element_count * 2 < capacity;