[C++-sig] Pyplusplus: operators <</>> not supported?

Hans Meine meine at informatik.uni-hamburg.de
Wed Jun 4 19:41:25 CEST 2008


Hi Roman!

Am Mittwoch, 04. Juni 2008 19:34:05 schrieben Sie:
> Can you send me link to the shift operator definition within a class?

I do not know any specific link to that.

> It could be nice to see your class too.

Attached is a simple variant of what I am doing.  BTW: Note the double warning 
from py++ - the ugly-name-warning should IMHO be removed, since the operator 
is ignored anyway.

> Take a look on next link, it will help you to modify generated code via
> Py++:
> http://language-binding.net/pyplusplus/documentation/inserting_code.html

Thanks.  I have already found that page in the meantime and successfully 
exploited the beauty of pygccxml. :-)

-- 
Ciao, /  /
     /--/
    /  / ANS
-------------- next part --------------
#ifndef VECTOR_HXX
#define VECTOR_HXX

template<class T>
class Vector2
{
public:
	T x, y;

	Vector2(T ix, T iy)
	: x(ix), y(iy)
	{}

	Vector2 operator+(Vector2 const &other) const
	{
		return Vector2(x + other.x, y + other.y);
	}

	Vector2 operator<<(int shift) const
	{
		return Vector2(x << shift, y << shift);
	}

	Vector2 operator>>(int shift) const
	{
		return Vector2(x >> shift, y >> shift);
	}
};

typedef Vector2<short> SVector2;

#endif // VECTOR_HXX


More information about the Cplusplus-sig mailing list