
On 2014-09-01, 11:00 AM, Robert Ramey wrote:
OK I see this now. I've used my method on a regular basis with good results - but it seems that I never had a case where the compile would fail on the false branch so it never came up for me.
Actually, I've used your method (not sure if it *is* yours, but I saw it in serialization code) for cases where it wouldn't compile on the false branch. In the linked example, there are 4 cases, but same idea as I think where you used it in serialization. The idea is something like this: template<typename T> void do_whatever_impl(boost::mpl::true_) { T::whatever(); } template<typename T> void do_whatever_impl(boost::mpl::false_) { // no T::whatever() whatever(); } template<typename T> void do_whatever() { do_whatever_impl(has_whatever<T>()); } https://bitbucket.org/cheez/dicpp/src/b78d05e976922f36959616cd2d98e55e5b1113... PS: I know I have to change to make_shared, just too lazy right now.