
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. First, we should add: #include <boost/type_traits/detail/yes_no_type.hpp> #include <boost/static_assert.hpp> to the top of <boost/operators.hpp>. Then dereferenceable class template definition (around 300 line of the same file): template <class T, class P, class B = ::boost::detail::empty_base> struct dereferenceable : B { P operator->() const { return &*static_cast<const T&>(*this); } }; should be changed as follows: namespace detail { template<class T> struct has_lvalue_const_dereference_ { private: template<class U> static ::boost::type_traits::yes_type discriminator_(U&(T::*)()const); template<class V> static ::boost::type_traits::no_type discriminator_(V(T::*)()const); static ::boost::type_traits::no_type discriminator_(...); public: BOOST_STATIC_CONSTANT(bool, value = sizeof( discriminator_( &T::operator* ) ) == sizeof( ::boost::type_traits::yes_type ) ); }; struct empty_base { }; } // namespace detail template <class T, class P, class B = ::boost::detail::empty_base> struct dereferenceable : B { P operator->() const { BOOST_STATIC_ASSERT( ::boost::detail::has_lvalue_const_dereference_<T>::value ); return &*static_cast<const T&>(*this); } }; That's it, I think. -- Pavel Kuznetsov MetaCommunications Engineering http://www.meta-comm.com/engineering