Rather than subclassing from the templated classes, just typedef directly to them.

This should solve the issues related to assigning to the convenience types.


git-svn-id: https://arducopter.googlecode.com/svn/trunk@543 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
DrZiplok@gmail.com 2010-09-23 05:45:43 +00:00
parent f72129bdb3
commit 7721e622aa
3 changed files with 15 additions and 121 deletions

View File

@ -122,41 +122,10 @@ public:
};
#define MATRIX3_CTORS(name, type) \
/* trivial ctor */ \
name() {} \
/* down casting ctor */ \
name(const Matrix3<type> &m): Matrix3<type>(m.a, m.b, m.c) {} \
/* make a,b,c combination into a matrix */ \
name(const Vector3<type> &a0, const Vector3<type> &b0, const Vector3<type> &c0) : Matrix3<type>(a0, b0, c0) {}
class Matrix3i : public Matrix3<int>
{
public:
MATRIX3_CTORS(Matrix3i, int)
};
class Matrix3ui : public Matrix3<unsigned int>
{
public:
MATRIX3_CTORS(Matrix3ui, unsigned int)
};
class Matrix3l : public Matrix3<long>
{
public:
MATRIX3_CTORS(Matrix3l, long)
};
class Matrix3ul : public Matrix3<unsigned long>
{
public:
MATRIX3_CTORS(Matrix3ul, unsigned long)
};
class Matrix3f : public Matrix3<float>
{
public:
MATRIX3_CTORS(Matrix3f, float)
};
typedef Matrix3<int> Matrix3i;
typedef Matrix3<unsigned int> Matrix3ui;
typedef Matrix3<long> Matrix3l;
typedef Matrix3<unsigned long> Matrix3ul;
typedef Matrix3<float> Matrix3f;
#endif // MATRIX3_H

View File

@ -149,45 +149,10 @@ struct Vector2
};
// macro to make creating the ctors for derived vectors easier
#define VECTOR2_CTORS(name, type) \
/* trivial ctor */ \
name() {} \
/* down casting ctor */ \
name(const Vector2<type> &v): Vector2<type>(v.x, v.y) {} \
/* make x,y combination into a vector */ \
name(type x0, type y0): Vector2<type>(x0, y0) {}
struct Vector2i: public Vector2<int>
{
VECTOR2_CTORS(Vector2i, int)
};
struct Vector2ui: public Vector2<unsigned int>
{
VECTOR2_CTORS(Vector2ui, unsigned int)
};
struct Vector2l: public Vector2<long>
{
VECTOR2_CTORS(Vector2l, long)
};
struct Vector2ul: public Vector2<unsigned long>
{
VECTOR2_CTORS(Vector2ul, unsigned long)
};
struct Vector2f: public Vector2<float>
{
VECTOR2_CTORS(Vector2f, float)
};
typedef Vector2<int> Vector2i;
typedef Vector2<unsigned int> Vector2ui;
typedef Vector2<long> Vector2l;
typedef Vector2<unsigned long> Vector2ul;
typedef Vector2<float> Vector2f;
#endif // VECTOR2_H

View File

@ -174,50 +174,10 @@ public:
};
// macro to make creating the ctors for derived vectors easier
#define VECTOR3_CTORS(name, type) \
/* trivial ctor */ \
name() {} \
/* down casting ctor */ \
name(const Vector3<type> &v): Vector3<type>(v.x, v.y, v.z) {} \
/* make x,y,z combination into a vector */ \
name(type x0, type y0, type z0): Vector3<type>(x0, y0, z0) {}
class Vector3i: public Vector3<int>
{
public:
VECTOR3_CTORS(Vector3i, int)
};
class Vector3ui: public Vector3<unsigned int>
{
public:
VECTOR3_CTORS(Vector3ui, unsigned int)
};
class Vector3l: public Vector3<long>
{
public:
VECTOR3_CTORS(Vector3l, long)
};
class Vector3ul: public Vector3<unsigned long>
{
public:
VECTOR3_CTORS(Vector3ul, unsigned long)
};
class Vector3f: public Vector3<float>
{
public:
VECTOR3_CTORS(Vector3f, float)
};
typedef Vector3<int> Vector3i;
typedef Vector3<unsigned int> Vector3ui;
typedef Vector3<long> Vector3l;
typedef Vector3<unsigned long> Vector3ul;
typedef Vector3<float> Vector3f;
#endif // VECTOR3_H