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

Kagamin spam at here.lot
Sat Oct 29 13:45:32 PDT 2011


unDEFER Wrote:

> 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.

try
val.get!(_WRAPPED_TYPE)


More information about the Digitalmars-d mailing list