Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-06-13 12:31:33


As I understand it the use of static_cast is essential. We have to
downcast the type of *this from dereferenceable<...> to const T&
so that we can get the T::operator*().

David Abrahams writes:
> 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
>
>
> ------------------------------------------------------------------------
> Never lose a file again. Protect yourself from accidental deletes,
> overwrites, and viruses with @Backup.
> Try @Backup it's easy, it's safe, and it's FREE!
> Click here to receive 300 MyPoints just for trying @Backup.
> http://click.egroups.com/1/5470/3/_/9351/_/960867367/
> ------------------------------------------------------------------------
>
>
>


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