Generated vec2

//generated on Mon Oct 31 22:02:37 2016

#ifndef VEC2_H
#define VEC2_H





//============================
// vec2
//============================
template <typename T>
struct vec2
 {
      inline vec2();
      inline explicit vec2(const T &xy);
      inline explicit vec2(const T *begin);
      inline vec2(const T &xv, const T &yv);
      inline vec2(const vec2<T> &that);
      inline vec2(const T (&that)[2]);

      inline T &x();
      inline const T &x() const;
      inline void setX(const T &x);
      inline T &y();
      inline const T &y() const;
      inline void setY(const T &y);

      inline unsigned int count() const;
      inline T &operator[](unsigned int i);
      inline const T &operator[](unsigned int i) const;

      inline T *begin();
      inline const T *begin() const;
      inline T *end();
      inline const T *end() const;

      inline vec2<T> &operator++();
      inline vec2<T> operator++(int);
      inline vec2<T> &operator--();
      inline vec2<T> operator--(int);


      inline vec2<T> &operator=(const vec2<T> &xy);
      inline vec2<T> operator+(const vec2<T> &xy) const;
      inline vec2<T> &operator+=(const vec2<T> &xy);
      inline vec2<T> operator-(const vec2<T> &xy) const;
      inline vec2<T> &operator-=(const vec2<T> &xy);
      inline vec2<T> operator*(const vec2<T> &xy) const;
      inline vec2<T> &operator*=(const vec2<T> &xy);
      inline vec2<T> operator/(const vec2<T> &xy) const;
      inline vec2<T> &operator/=(const vec2<T> &xy);
      inline vec2<T> operator%(const vec2<T> &xy) const;
      inline vec2<T> &operator%=(const vec2<T> &xy);
      inline bool operator<(const vec2<T> &xy) const;
      inline bool operator<=(const vec2<T> &xy) const;
      inline bool operator>(const vec2<T> &xy) const;
      inline bool operator>=(const vec2<T> &xy) const;
      inline bool operator==(const vec2<T> &xy) const;
      inline bool operator!=(const vec2<T> &xy) const;
      inline vec2<T> operator<<(const vec2<T> &xy) const;
      inline vec2<T> &operator<<=(const vec2<T> &xy);
      inline vec2<T> operator>>(const vec2<T> &xy) const;
      inline vec2<T> &operator>>=(const vec2<T> &xy);
      inline vec2<T> operator|(const vec2<T> &xy) const;
      inline vec2<T> &operator|=(const vec2<T> &xy);
      inline vec2<T> operator^(const vec2<T> &xy) const;
      inline vec2<T> &operator^=(const vec2<T> &xy);
      inline vec2<T> operator&(const vec2<T> &xy) const;
      inline vec2<T> operator&=(const vec2<T> &xy) const;
      inline bool operator||(const vec2<T> &xy) const;


      inline vec2<T> operator*(const T &xy) const;
      inline vec2<T> &operator*=(const T &xy);
      inline vec2<T> operator/(const T &xy) const;
      inline vec2<T> &operator/=(const T &xy);
      inline vec2<T> operator%(const T &xy) const;
      inline vec2<T> &operator%=(const T &xy);

      inline vec2<T> operator-() const;
      inline vec2<T> operator+() const;
      inline bool operator!() const;

      inline T (&xy)[2]();
      inline const T (&xy)[2]() const;
      inline void setXY(const T (&them)[2]);
      inline T (&array)[2]();
      inline const T (&array)[2]() const;
      inline operator T (&)[2]();
      inline operator const T (&)[2]() const;

      template <typename T1>
      inline vec2<T1> to();

   private:
      T xv;
      T yv;
 };


















template <typename T>
T &vec2<T>::x()
   { return xv; }

template <typename T>
const T &vec2<T>::x() const
   { return xv; }

template <typename T>
void vec2<T>::setX(const T &x)
   { xv=x; }

template <typename T>
T &vec2<T>::y()
   { return yv; }

template <typename T>
const T &vec2<T>::y() const
   { return yv; }

template <typename T>
void vec2<T>::setY(const T &y)
   { yv=y; }

template <typename T>
vec2<T>::vec2()
 :xv(0),
  yv(0)
   {
   }

template <typename T>
vec2<T>::vec2(const T &xy)
 :xv(xy),
  yv(xy)
   {
   }

template <typename T>
vec2<T>::vec2(const T *begin)
 :xv(begin[0]),
  yv(begin[1])
   {
   }

template <typename T>
vec2<T>::vec2(const T &xv, const T &yv)
 :xv(xv),
  yv(yv)
   {
   }

template <typename T>
vec2<T>::vec2(const vec2<T> &that)
 :xv(that.xv),
  yv(that.yv)
   {
   }

template <typename T>
T *vec2<T>::begin()
   { return &xv; }

template <typename T>
const T *vec2<T>::begin() const
   { return &xv; }

template <typename T>
unsigned int vec2<T>::count() const
   { return 2; }

template <typename T>
T *vec2<T>::end()
   { return begin()+count(); }

template <typename T>
const T *vec2<T>::end() const
   { return begin()+count(); }

template <typename T>
T &vec2<T>::operator[](unsigned int i)
   {
      J_ASSERT(i<count(), "Index out of range!");
      return *(begin()+i);
   }

template <typename T>
const T &vec2<T>::operator[](unsigned int i) const
   {
      J_ASSERT(i<count(), "Index out of range!");
      return *(begin()+i);
   }

template <typename T>
vec2<T> &vec2<T>::operator++()
   {
      ++xv;
      ++yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator++(int)
   { return vec2<T>(xv++, yv++); }

template <typename T>
vec2<T> &vec2<T>::operator--()
   {
      --xv;
      --yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator--(int)
   { return vec2<T>(xv--, yv--); }

template <typename T>
vec2<T> &vec2<T>::operator=(const vec2<T> &xy)
   {
      xv=xy.xv;
      yv=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator+(const vec2<T> &xy) const
   { return vec2<T>(xv+xy.xv, yv+xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator+=(const vec2<T> &xy)
   {
      xv+=xy.xv;
      yv+=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator-(const vec2<T> &xy) const
   { return vec2<T>(xv-xy.xv, yv-xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator-=(const vec2<T> &xy)
   {
      xv-=xy.xv;
      yv-=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator*(const vec2<T> &xy) const
   { return vec2<T>(xv*xy.xv, yv*xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator*=(const vec2<T> &xy)
   {
      xv*=xy.xv;
      yv*=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator/(const vec2<T> &xy) const
   { return vec2<T>(xv/xy.xv, yv/xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator/=(const vec2<T> &xy)
   {
      xv/=xy.xv;
      yv/=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator%(const vec2<T> &xy) const
   { return vec2<T>(xv%xy.xv, yv%xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator%=(const vec2<T> &xy)
   {
      xv%=xy.xv;
      yv%=xy.yv;
      return *this;
   }

template <typename T>
bool vec2<T>::operator<(const vec2<T> &xy) const
   { return (xv<xy.xv) && (yv<xy.yv); }

template <typename T>
bool vec2<T>::operator<=(const vec2<T> &xy) const
   { return (xv<=xy.xv) && (yv<=xy.yv); }

template <typename T>
bool vec2<T>::operator>(const vec2<T> &xy) const
   { return (xv>xy.xv) && (yv>xy.yv); }

template <typename T>
bool vec2<T>::operator>=(const vec2<T> &xy) const
   { return (xv>=xy.xv) && (yv>=xy.yv); }

template <typename T>
bool vec2<T>::operator==(const vec2<T> &xy) const
   { return (xv==xy.xv) && (yv==xy.yv); }

template <typename T>
bool vec2<T>::operator!=(const vec2<T> &xy) const
   { return (xv!=xy.xv) || (yv!=xy.yv); }

template <typename T>
vec2<T> vec2<T>::operator<<(const vec2<T> &xy) const
   { return vec2<T>(xv<<xy.xv, yv<<xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator<<=(const vec2<T> &xy)
   {
      xv<<=xy.xv;
      yv<<=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator>>(const vec2<T> &xy) const
   { return vec2<T>(xv>>xy.xv, yv>>xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator>>=(const vec2<T> &xy)
   {
      xv>>=xy.xv;
      yv>>=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator|(const vec2<T> &xy) const
   { return vec2<T>(xv|xy.xv, yv|xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator|=(const vec2<T> &xy)
   {
      xv|=xy.xv;
      yv|=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator^(const vec2<T> &xy) const
   { return vec2<T>(xv^xy.xv, yv^xy.yv); }

template <typename T>
vec2<T> &vec2<T>::operator^=(const vec2<T> &xy)
   {
      xv^=xy.xv;
      yv^=xy.yv;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator&(const vec2<T> &xy) const
   { return vec2<T>(xv&xy.xv, yv&xy.yv); }

template <typename T>
vec2<T> vec2<T>::operator&=(const vec2<T> &xy) const
   { return vec2<T>(xv&=xy.xv, yv&=xy.yv); }

template <typename T>
bool vec2<T>::operator||(const vec2<T> &xy) const
   { return (xv||xy.xv) || (yv||xy.yv); }

template <typename T>
vec2<T> vec2<T>::operator*(const T &xy) const
   { return vec2<T>(xv*xy, yv*xy); }

template <typename T>
vec2<T> &vec2<T>::operator*=(const T &xy)
   {
      xv*=xy;
      yv*=xy;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator/(const T &xy) const
   { return vec2<T>(xv/xy, yv/xy); }

template <typename T>
vec2<T> &vec2<T>::operator/=(const T &xy)
   {
      xv/=xy;
      yv/=xy;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator%(const T &xy) const
   { return vec2<T>(xv%xy, yv%xy); }

template <typename T>
vec2<T> &vec2<T>::operator%=(const T &xy)
   {
      xv%=xy;
      yv%=xy;
      return *this;
   }

template <typename T>
vec2<T> vec2<T>::operator-() const
   { return vec2<T>(-xv, -yv); }

template <typename T>
vec2<T> vec2<T>::operator+() const
   { return vec2<T>(+xv, +yv); }

template <typename T>
bool vec2<T>::operator!() const
   { return (!xv) && (!yv); }

template <typename T>
T (&vec2<T>::xy)[2]()
   { return *reinterpret_cast<T (*)[2]>(begin()); }

template <typename T>
const T (&vec2<T>::xy)[2]() const
   { return *reinterpret_cast<const T (*)[2]>(begin()); }

template <typename T>
void vec2<T>::setXY(const T (&them)[2])
   { memcpy(xy(), them, sizeof(T[2])); }

template <typename T>
T (&vec2<T>::array)[2]()
   { return *reinterpret_cast<T (*)[2]>(begin()); }

template <typename T>
const T (&vec2<T>::array)[2]() const
   { return *reinterpret_cast<const T (*)[2]>(begin()); }

template <typename T>
vec2<T>::operator T (&)[2]()
   { return array(); }

template <typename T>
vec2<T>::operator const T (&)[2]() const
   { return array(); }

template <typename T, typename T1>
vec2<T1> vec2<T>::to()
   { return vec2<T1>(static_cast<T1>(xv), static_cast<T1>(yv)); }

template <typename T>
vec2<T>::vec2(const T (&that)[2])
 :xv(that[0]),
  yv(that[1])
   {
   }

#endif  // VEC2_H

//this header was generated in 5 milliseconds

No comments:

Post a Comment

Pages