/*
Copyright 2014 Michele "King_DuckZ" Santullo
This file is part of CloonelJump.
CloonelJump is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CloonelJump is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CloonelJump. If not, see .
*/
#ifndef idid0528646832E04CF08E9785B66CFE0BD1
#define idid0528646832E04CF08E9785B66CFE0BD1
#include
#include
#include
namespace cloonel {
template
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 = default;
enum {
Dimension = S
};
template = S> > T& x ( void ) { return m_mem[0]; }
template = S> > const T& x ( void ) const { return m_mem[0]; }
template = 2 and 4 >= S> > T& y ( void ) { return m_mem[1]; }
template = 2 and 4 >= S> > const T& y ( void ) const { return m_mem[1]; }
template = 3 and 4 >= S> > T& z ( void ) { return m_mem[2]; }
template = 3 and 4 >= S> > const T& z ( void ) const { return m_mem[2]; }
template = 4 and 4 >= S> > T& w ( void ) { return m_mem[3]; }
template = 4 and 4 >= S> > const T& w ( void ) const { return m_mem[3]; }
template const Vector& operator+= ( const Vector& parOther );
template const Vector& operator-= ( const Vector& parOther );
template const Vector& operator*= ( const Vector& parOther );
template const Vector& operator/= ( const Vector& parOther );
template const Vector& operator+= ( U parOther );
template const Vector& operator-= ( U parOther );
template const Vector& operator*= ( U parOther );
template const Vector& operator/= ( U parOther );
T& operator[] ( uint32_t parIndex ) { return m_mem[parIndex]; }
const T& operator[] ( uint32_t parIndex ) const { return m_mem[parIndex]; }
private:
T m_mem[S];
};
template
Vector::type, S> operator+ ( Vector parA, const Vector& parB ) __attribute__((pure));
template
Vector::type, S> operator- ( Vector parA, const Vector& parB ) __attribute__((pure));
template
Vector::type, S> operator* ( Vector parA, const Vector& parB ) __attribute__((pure));
template
Vector::type, S> operator/ ( Vector parA, const Vector& parB ) __attribute__((pure));
template
Vector::type, S> operator+ ( U parA, const Vector& parB ) __attribute__((pure));
template
Vector::type, S> operator- ( U parA, const Vector& parB ) __attribute__((pure));
template
Vector::type, S> operator* ( U parA, const Vector& parB ) __attribute__((pure));
template
Vector::type, S> operator/ ( U parA, const Vector& parB ) __attribute__((pure));
template
Vector::type, S> operator+ ( const Vector& parA, U parB ) __attribute__((pure));
template
Vector::type, S> operator- ( const Vector& parA, U parB ) __attribute__((pure));
template
Vector::type, S> operator* ( const Vector& parA, U parB ) __attribute__((pure));
template
Vector::type, S> operator/ ( const Vector& parA, U parB ) __attribute__((pure));
template
bool operator< ( const Vector& parA, const Vector& parB ) __attribute__((pure));
template
bool operator> ( const Vector& parA, const Vector& parB ) __attribute__((pure));
template
bool operator<= ( const Vector& parA, const Vector& parB ) __attribute__((pure));
template
bool operator>= ( const Vector& parA, const Vector& parB ) __attribute__((pure));
template
bool operator== ( const Vector& parA, const Vector& parB ) __attribute__((pure));
template
bool operator!= ( const Vector& parA, const Vector& parB ) __attribute__((pure));
typedef Vector float2;
typedef Vector ushort2;
typedef Vector int2;
} //namespace cloonel
#include "vector.inl"
#endif