Sign in to follow this  

Class Binding Utility

Recommended Posts

If you find yourself binding a lot of classes that all have the basic operators, you might find this little template usefull. Instead of writing lots of wrapper functions, just grab them out of the template! Instead of
. The wrapper is generated for you. Use with the calling convention asCALL_CDECL_OBJLAST.

template <typename T>
class CDA
	static void Construct(T* ptr) { new (ptr) T(); }
	static void CopyConstruct(const T& rhs, T* ptr) { new (ptr) T(rhs); }
	static void Destroy(T* ptr) { ptr->~T(); }
	static T& Assign(const T& rhs, T* ptr) { return (*ptr) = rhs; }


I plan on expanding this to cover wrappers for all binary operators (And probably the unary operators too, just for consistency) before releasing it as part of my AutoBind utility I am working on. By then, it will be changed so that the template will still compile if your class does not support a certain operator. Just don't try and bind that operator. [PS - Witchlord; does 2.x support the pre/post increment/decrement operators?]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this