Skip to content

Commit

Permalink
Protect dereferenceable<> against overloaded operator&, fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Nov 23, 2017
1 parent a6c175e commit ad0fc7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/boost/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -98,6 +99,7 @@

#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/core/addressof.hpp>

#if defined(__sgi) && !defined(__GNUC__)
# pragma set woff 1234
Expand Down Expand Up @@ -302,7 +304,7 @@ struct dereferenceable : B
{
P operator->() const
{
return &*static_cast<const T&>(*this);
return ::boost::addressof(*static_cast<const T&>(*this));
}
};

Expand Down
4 changes: 2 additions & 2 deletions operators.htm
Original file line number Diff line number Diff line change
Expand Up @@ -1667,8 +1667,8 @@ <h3><a name="dereference">Dereference</a> Operators</h3>

<td><code>P operator-&gt;() const</code></td>

<td><code>(&amp;*i)</code>. Return convertible to
<code>P</code>.</td>
<td><code>*i</code>. Address of the returned value convertible
to <code>P</code>.</td>
</tr>

<tr>
Expand Down

0 comments on commit ad0fc7c

Please sign in to comment.