Boost logo

Boost :

From: Daniel Wallin (daniel_at_[hidden])
Date: 2007-01-21 13:30:59


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> >
  {};

-- 
Daniel Wallin
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk