Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-08-24 02:34:01

"Pavel Kuznetsov" <pavel_at_[hidden]> writes:

> David,
>>> Ok, I got your point. But maybe then it might be a good idea to add
>>> some kind of compile-time assert to
>>> boost::dereferenceable<>::operator->()?
>> I'd be happy to evaluate your patch containing an assert.
> Here it is.

Looks way too heavy to me for what it's accomplishing.

How about:

namespace error
  template <class T, class Value>
  int dereferenceable_requires_lvalue_dereference(Value&);

template <class T, class P, class B = ::boost::detail::empty_base>
struct dereferenceable : B
   P operator->() const
        assertion = sizeof(
             *static_cast<const T&>(*this)
     return &*static_cast<const T&>(*this);


Does that work?

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at