From 7a200905ddb38b14afeabc8312d2665052c5c51f Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 13 Jan 2022 16:34:47 +0300 Subject: [PATCH] Added an assignment operator to counting_iterator. This should silence gcc warnings about deprecated implicit copy assignment operator because of the explicitly defined copy constructor. Also, changed constructor definitions to be defaulted when possible and added missing includes. Closes https://github.com/boostorg/iterator/pull/69. --- include/boost/iterator/counting_iterator.hpp | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/include/boost/iterator/counting_iterator.hpp b/include/boost/iterator/counting_iterator.hpp index 9bb0419..89dbe99 100644 --- a/include/boost/iterator/counting_iterator.hpp +++ b/include/boost/iterator/counting_iterator.hpp @@ -5,6 +5,16 @@ #ifndef COUNTING_ITERATOR_DWA200348_HPP # define COUNTING_ITERATOR_DWA200348_HPP +# include +# include +# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +# include +# elif !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551)) +# include +# else +# include +# endif +# include # include # include # include @@ -45,7 +55,7 @@ namespace detail && boost::is_convertible::value )); # else - BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic::value); + BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic::value); # endif # endif @@ -77,8 +87,6 @@ namespace detail typedef typename boost::detail::numeric_traits::difference_type type; }; - BOOST_STATIC_ASSERT(is_numeric::value); - template struct counting_iterator_base { @@ -161,9 +169,9 @@ class counting_iterator public: typedef typename super_t::difference_type difference_type; - counting_iterator() { } + BOOST_DEFAULTED_FUNCTION(counting_iterator(), {}) - counting_iterator(counting_iterator const& rhs) : super_t(rhs.base()) {} + BOOST_DEFAULTED_FUNCTION(counting_iterator(counting_iterator const& rhs), : super_t(rhs.base()) {}) counting_iterator(Incrementable x) : super_t(x) @@ -180,6 +188,8 @@ class counting_iterator {} # endif + BOOST_DEFAULTED_FUNCTION(counting_iterator& operator=(counting_iterator const& rhs), { *static_cast< super_t* >(this) = static_cast< super_t const& >(rhs); return *this; }) + private: typename super_t::reference dereference() const @@ -206,8 +216,8 @@ template inline counting_iterator make_counting_iterator(Incrementable x) { - typedef counting_iterator result_t; - return result_t(x); + typedef counting_iterator result_t; + return result_t(x); } } // namespace iterators