
"Pavel Kuznetsov" <pavel@despammed.com> writes:
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); } };
No good, I'm afraid. You can define a unary non-member operator*: struct X {}; int operator*(X const&); -- Dave Abrahams Boost Consulting http://www.boost-consulting.com