
Daniel Wallin wrote:
John Maddock wrote:
Dmitry Ivankov wrote:
Doesn't work for void operator*(B&), but can we call such class dereferencable? :)
No, I think there will always be some corner cases like that where it blows up, but does anyone really write such an operator in practice?
It's quite possible to handle the case where *x is void. See for example boost/detail/is_incrementable.hpp. A couple of years ago, I tried to generalize this into something reusable and more powerful. The result of that is available in the sandbox; boost/result_check.hpp. The intended usage was something like:
BOOST_RESULT_CHECK(1, operator*, dereference, *_1) ^ ^ ^ ^ arity ----' | | | function -' | | metafunction name -' | operation -'
template <class T> struct is_dereferencable : check_dereference<T> {};
template <class T> struct is_dereference_void : check_dereference<T, boost::is_void<mpl::_> > {};
template <class T, class U> struct is_dereference_convertible_to : check_dereference<T, boost::is_convertible<mpl::_, U> > {};
Very interesting, I've had a play with that, and it does indeed seem to be a superior solution. Thanks! John.