Argument of template as method of the object (How to replace the macros)

unDEFER undefer at gmail.com
Sat Oct 29 13:28:45 PDT 2011


Hello!
Say me please, what the best way to replace the next C++ macros (code from
BerkeleyDB) in D:

#define	WRAPPED_CLASS(_WRAPPER_CLASS, _IMP_CLASS, _WRAPPED_TYPE)           \
	class _IMP_CLASS {};                                               \
									   \
	inline _WRAPPED_TYPE *unwrap(_WRAPPER_CLASS *val)                  \
	{                                                                  \
		if (!val) return (0);                                      \
		return (val->get_##_WRAPPED_TYPE());                       \
	}                                                                  \
									   \
	inline const _WRAPPED_TYPE *unwrapConst(const _WRAPPER_CLASS *val) \
	{                                                                  \
		if (!val) return (0);                                      \
		return (val->get_const_##_WRAPPED_TYPE());                 \
	}

I'm already search several hours but can't find good example in the
documentation.
Thank you in advance.


More information about the Digitalmars-d mailing list