From ad0fc7c9d3d21d5ae3d594c41ed47ca71f24ca09 Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Thu, 23 Nov 2017 21:14:07 +0100 Subject: [PATCH] Protect dereferenceable<> against overloaded operator&, fixes #35 --- include/boost/operators.hpp | 4 +++- operators.htm | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/boost/operators.hpp b/include/boost/operators.hpp index 11bca21..156571c 100644 --- a/include/boost/operators.hpp +++ b/include/boost/operators.hpp @@ -9,6 +9,7 @@ // See http://www.boost.org/libs/utility/operators.htm for documentation. // Revision History +// 23 Nov 17 Protect dereferenceable<> from overloaded operator&. // 15 Oct 17 Adapted to C++17, replace std::iterator<> with manual // implementation. // 22 Feb 16 Added ADL protection, preserve old work-arounds in @@ -98,6 +99,7 @@ #include #include +#include #if defined(__sgi) && !defined(__GNUC__) # pragma set woff 1234 @@ -302,7 +304,7 @@ struct dereferenceable : B { P operator->() const { - return &*static_cast(*this); + return ::boost::addressof(*static_cast(*this)); } }; diff --git a/operators.htm b/operators.htm index 37820e1..993436c 100644 --- a/operators.htm +++ b/operators.htm @@ -1667,8 +1667,8 @@ T operator+( T lhs, const T& rhs ) P operator->() const - (&*i). Return convertible to - P. + *i. Address of the returned value convertible + to P.