@UncleBens: I donβt want to edit your message, here is an example code (I hope it is ready for copy / paste), put it in your post and comment on this answer so that I can delete it :)
template <class T> class HasPrint1 { public: struct type { enum { value = ( sizeof(dummy((T*)0)) == sizeof(yes_t) ) }; }; typedef char yes_t; struct no_t { yes_t[2] m; }; template <class C> static yes_t dummy(C*, size_t = sizeof(&C::print1)); static no_t dummy(...); };
I took the liberty of adding the disable_if parameter to show similarities with the if / else if / else block.
I would love some feedback.
source share