
David,
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 { enum { assertion = sizeof( error::dereferenceable_requires_lvalue_dereference<T>( *static_cast<const T&>(*this) )) }; return &*static_cast<const T&>(*this); } }; ?? Does that work?
Alas, that does not, since at least MSVC allows binding rvalue to non-const reference. But we can simplify original approach along these lines: namespace error { template <class T, class Value> int dereferenceable_requires_lvalue_dereference( Value& (T::*)()const); } template <class T, class P, class B = ::boost::detail::empty_base> struct dereferenceable : B { P operator->() const { enum { assertion = sizeof( error::dereferenceable_requires_lvalue_dereference<T>( &T::operator* )) }; return &*static_cast<const T&>(*this); } }; -- Pavel Kuznetsov MetaCommunications Engineering http://www.meta-comm.com/engineering