On Fri, 23 Sep 2011 00:51:40 -0700, Robert Jones
Hi All
This doesn't work.
template<typename T> struct S { typename disable_if
::type mutating_method(); }; I understand why not, although only after the compiler threw it out, but obviously (in hindsight), the method itself is not a template, so can't be selectively instantiated.
The question is whether and how I can achieve the effect I'm after, ie., that the method is not present if the struct is instantiated with a const type?
Thx, Rob.
See http://thread.gmane.org/gmane.comp.lib.boost.devel/222181/focus=222402 Short answer (from the cited post):
template <class U> struct T { void f() { f_impl(
(0)); } private: template <class T> typename enable_if< mpl::and_< is_convertible
, some_condition_on<U> ::type f_impl(T) { .... } };
Basically introduce a dummy parameter with a dummy template type that's not used in f_impl. Mostafa