Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-06-12 22:36:25


I am concerned abou the following incantation in operators.hpp:

template <class T, class V, class D = boost::detail::empty_base>
struct dereferenceable : D
{
  V* operator->() const
  {
    return &*static_cast<const T&>(*this);
  }
};

What is the purpose of the static_cast here? If it is useful, wouldn't it be
much safer to write:

template <class T, class V, class D = boost::detail::empty_base>
struct dereferenceable : D
{
  V* operator->() const
  { const T& x = *this; return &*x; }
};

??
Thanks,
Dave


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