Vector3: Inline constructors
authorOskar Linde <oskar.linde@gmail.com>
Sun, 6 Sep 2015 16:25:58 +0000 (09:25 -0700)
committerOskar Linde <oskar.linde@gmail.com>
Sun, 6 Sep 2015 17:27:20 +0000 (10:27 -0700)
src/libs/Vector3.cpp
src/libs/Vector3.h

index 3129893..4d2cde4 100644 (file)
@@ -5,35 +5,6 @@
 
 float Vector3::nan = NAN;
 
-Vector3::Vector3()
-{
-    elem[0] = elem[1] = elem[2] = 0.0F;
-}
-
-Vector3::Vector3(float a, float b, float c)
-{
-    elem[0] = a;
-    elem[1] = b;
-    elem[2] = c;
-}
-
-Vector3::Vector3(const Vector3 &to_copy)
-{
-    elem[0] = to_copy.elem[0];
-    elem[1] = to_copy.elem[1];
-    elem[2] = to_copy.elem[2];
-}
-
-Vector3& Vector3::operator= (const Vector3 &to_copy)
-{
-    if( this != &to_copy ) {
-        elem[0] = to_copy.elem[0];
-        elem[1] = to_copy.elem[1];
-        elem[2] = to_copy.elem[2];
-    }
-    return *this;
-}
-
 float Vector3::operator[](int i) const
 {
     if (i >= 0 && i <= 2)
index 3ea5852..be51f8f 100644 (file)
@@ -4,10 +4,9 @@
 class Vector3
 {
 public:
-    Vector3();
-    Vector3(float, float, float);
-    Vector3(const Vector3& to_copy);
-    Vector3& operator= (const Vector3& to_copy);
+    Vector3() = default;
+    Vector3(float a, float b, float c) : elem{a,b,c} {}
+    Vector3(const Vector3& to_copy) = default;
 
     float    operator[](int) const;
     void     set(float a, float b, float c);
@@ -27,7 +26,7 @@ public:
     Vector3  unit(void) const;
 
 private:
-    float  elem[3];
+    float  elem[3]{};
     static float nan;
 };