diff --git a/src/vector.hpp b/src/vector.hpp index 696d92a..190b7a6 100644 --- a/src/vector.hpp +++ b/src/vector.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #if !defined(NDEBUG) #include @@ -33,12 +34,12 @@ namespace cloonel { class Vector { template friend class Vector; public: - Vector ( void ) = default; - explicit Vector ( T parValue ); - template explicit Vector ( const Vector& parOther ); - template > Vector ( T parX, T parY ) : m_mem {parX, parY} {} - template > Vector ( T parX, T parY, T parZ ) : m_mem {parX, parY, parZ} {} - template > Vector ( T parX, T parY, T parZ, T parW ) : m_mem {parX, parY, parZ, parW} {} + Vector ( void ) noexcept(noexcept(T())) = default; + explicit Vector ( T parValue ) noexcept(noexcept(T()) && noexcept(parValue=parValue)); + template explicit Vector ( const Vector& parOther ) noexcept(noexcept(T()) && noexcept(const_cast(parOther.m_mem[0])=T())); + template > Vector ( T parX, T parY ) noexcept : m_mem {parX, parY} {} + template > Vector ( T parX, T parY, T parZ ) noexcept : m_mem {parX, parY, parZ} {} + template > Vector ( T parX, T parY, T parZ, T parW ) noexcept : m_mem {parX, parY, parZ, parW} {} ~Vector ( void ) noexcept = default; diff --git a/src/vector.inl b/src/vector.inl index 2059621..b435379 100644 --- a/src/vector.inl +++ b/src/vector.inl @@ -21,20 +21,16 @@ namespace cloonel { ///------------------------------------------------------------------------- ///------------------------------------------------------------------------- template - Vector::Vector (T parValue) { - for (uint32_t z = 0; z < S; ++z) { - m_mem[z] = parValue; - } + Vector::Vector (T parValue) noexcept(noexcept(T()) && noexcept(parValue=parValue)) { + std::fill(m_mem, m_mem + S, parValue); } ///------------------------------------------------------------------------- ///------------------------------------------------------------------------- template template - Vector::Vector (const Vector& parOther) { - for (uint32_t z = 0; z < S; ++z) { - m_mem[z] = static_cast(parOther.m_mem[z]); - } + Vector::Vector (const Vector& parOther) noexcept(noexcept(T()) && noexcept(const_cast(parOther.m_mem[0])=T())) { + std::copy(parOther.m_mem, parOther.m_mem + S, m_mem); } #pragma GCC diagnostic push