• Advertisement
Sign in to follow this  

Class Binding Utility

This topic is 4530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement