From 6ae6ff79f10b0ed5abe1ba3c43371583279ef4c3 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 23 Dec 2021 16:41:32 +0300 Subject: [PATCH] Deprecated boost/iterator.hpp, emit warnings on inclusion. The header defines boost::iterator template, which is an alias for std::iterator, which is itself deprecated since C++17. Updated test to avoid testing the definition in C++17 onwards to avoid failures due to deprecation warnings from libc++-13. --- doc/changes.qbk | 1 + include/boost/iterator.hpp | 4 +++- test/iterator_test.cpp | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/changes.qbk b/doc/changes.qbk index 88f0d2b..905098b 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -10,6 +10,7 @@ * Added `boost::allocator_traits`, an implementation of `std::allocator_traits`. * Made `boost::pointer_traits` SFINAE friendly. +* `boost/iterator.hpp` is deprecated and will be removed in a future release. The header defines `boost::iterator` template, which is equivalent to `std::iterator` in `` header. However, since `std::iterator` is itself deprecated in C++17, users are advised to remove `boost::iterator` or `std::iterator` use from their code. [endsect] diff --git a/include/boost/iterator.hpp b/include/boost/iterator.hpp index c9c6197..4a780e8 100644 --- a/include/boost/iterator.hpp +++ b/include/boost/iterator.hpp @@ -5,7 +5,9 @@ #ifndef BOOST_ITERATOR_HPP #define BOOST_ITERATOR_HPP -// This header is obsolete and will be deprecated. +#include + +BOOST_HEADER_DEPRECATED("") #include #include // std::ptrdiff_t diff --git a/test/iterator_test.cpp b/test/iterator_test.cpp index c0e64a3..3cbf038 100644 --- a/test/iterator_test.cpp +++ b/test/iterator_test.cpp @@ -8,8 +8,15 @@ // http://www.boost.org/LICENSE_1_0.txt // +#define BOOST_ALLOW_DEPRECATED_HEADERS #define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING +#include + +// std::iterator template is deprecated in C++17. Some standard libraries emit warnings +// that cannot be easily suppressed, so disable the tests in C++17 onwards. +#if BOOST_CXX_VERSION < 201703 + #include #include #include @@ -69,3 +76,11 @@ int main() return boost::report_errors(); } + +#else // BOOST_CXX_VERSION < 201703 + +int main() +{ +} + +#endif // BOOST_CXX_VERSION < 201703