summaryrefslogtreecommitdiff
path: root/boost/operators.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/operators.hpp')
-rw-r--r--boost/operators.hpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/boost/operators.hpp b/boost/operators.hpp
index 3fc08d5e8d..156571c1a9 100644
--- a/boost/operators.hpp
+++ b/boost/operators.hpp
@@ -1,7 +1,7 @@
// Boost operators.hpp header file ----------------------------------------//
// (C) Copyright David Abrahams, Jeremy Siek, Daryle Walker 1999-2001.
-// (C) Copyright Daniel Frey 2002-2016.
+// (C) Copyright Daniel Frey 2002-2017.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -9,6 +9,9 @@
// 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
// operators_v1.hpp and clean up this file. (Daniel Frey)
// 16 Dec 10 Limit warning suppression for 4284 to older versions of VC++
@@ -96,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
@@ -300,7 +304,7 @@ struct dereferenceable : B
{
P operator->() const
{
- return &*static_cast<const T&>(*this);
+ return ::boost::addressof(*static_cast<const T&>(*this));
}
};
@@ -824,6 +828,21 @@ template <class T> struct operators<T, T>
// Iterator helper classes (contributed by Jeremy Siek) -------------------//
// (Input and output iterator helpers contributed by Daryle Walker) -------//
// (Changed to use combined operator classes by Daryle Walker) ------------//
+// (Adapted to C++17 by Daniel Frey) --------------------------------------//
+template <class Category,
+ class T,
+ class Distance = std::ptrdiff_t,
+ class Pointer = T*,
+ class Reference = T&>
+struct iterator_helper
+{
+ typedef Category iterator_category;
+ typedef T value_type;
+ typedef Distance difference_type;
+ typedef Pointer pointer;
+ typedef Reference reference;
+};
+
template <class T,
class V,
class D = std::ptrdiff_t,
@@ -831,13 +850,13 @@ template <class T,
class R = V const &>
struct input_iterator_helper
: input_iteratable<T, P
- , std::iterator<std::input_iterator_tag, V, D, P, R
+ , iterator_helper<std::input_iterator_tag, V, D, P, R
> > {};
template<class T>
struct output_iterator_helper
: output_iteratable<T
- , std::iterator<std::output_iterator_tag, void, void, void, void
+ , iterator_helper<std::output_iterator_tag, void, void, void, void
> >
{
T& operator*() { return static_cast<T&>(*this); }
@@ -851,7 +870,7 @@ template <class T,
class R = V&>
struct forward_iterator_helper
: forward_iteratable<T, P
- , std::iterator<std::forward_iterator_tag, V, D, P, R
+ , iterator_helper<std::forward_iterator_tag, V, D, P, R
> > {};
template <class T,
@@ -861,7 +880,7 @@ template <class T,
class R = V&>
struct bidirectional_iterator_helper
: bidirectional_iteratable<T, P
- , std::iterator<std::bidirectional_iterator_tag, V, D, P, R
+ , iterator_helper<std::bidirectional_iterator_tag, V, D, P, R
> > {};
template <class T,
@@ -871,7 +890,7 @@ template <class T,
class R = V&>
struct random_access_iterator_helper
: random_access_iteratable<T, P, D, R
- , std::iterator<std::random_access_iterator_tag, V, D, P, R
+ , iterator_helper<std::random_access_iterator_tag, V, D, P, R
> >
{
friend D requires_difference_operator(const T& x, const T& y) {