From: Andrei Pavel Date: Tue, 6 Dec 2022 13:28:44 +0000 (+0200) Subject: [#2617] fix Wdeprecated-declarations warnings on std::iterator X-Git-Tag: Kea-2.3.4~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4d61bf7b2add5eb5ec5d7f7ce03750a4e39de3c;p=thirdparty%2Fkea.git [#2617] fix Wdeprecated-declarations warnings on std::iterator Like this one: ../../../src/lib/dns/message.h:91:37: warning: ‘template struct std::iterator’ is deprecated [-Wdeprecated-declarations] 91 | class SectionIterator : public std::iterator { | ^~~~~~~~ --- diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h index da8acfe648..410265d489 100644 --- a/src/lib/dns/message.h +++ b/src/lib/dns/message.h @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2009-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -88,8 +88,15 @@ struct SectionIteratorImpl; /// The template parameter is either \c QuestionPtr (for the question section) /// or \c RRsetPtr (for the answer, authority, or additional section). template -class SectionIterator : public std::iterator { +class SectionIterator { public: + // Aliases used to enable iterator behavior on this class + using iterator_category = std::input_iterator_tag; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T*; + using reference = T&; + SectionIterator() : impl_(NULL) {} SectionIterator(const SectionIteratorImpl& impl); ~SectionIterator(); @@ -673,10 +680,8 @@ typedef boost::shared_ptr ConstMessagePtr; /// \return A reference to the same \c std::ostream object referenced by /// parameter \c os after the insertion operation. std::ostream& operator<<(std::ostream& os, const Message& message); -} -} -#endif // MESSAGE_H -// Local Variables: -// mode: c++ -// End: +} // namespace dns +} // namespace isc + +#endif // MESSAGE_H diff --git a/src/lib/dns/rrset_collection_base.h b/src/lib/dns/rrset_collection_base.h index ac77756e41..a8ca2551c6 100644 --- a/src/lib/dns/rrset_collection_base.h +++ b/src/lib/dns/rrset_collection_base.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015,2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -153,10 +153,15 @@ public: /// /// It behaves like a \c std::iterator forward iterator, so please /// see its documentation for usage. - class Iterator : std::iterator - { + class Iterator { public: + // Aliases used to enable iterator behavior on this class + using iterator_category = std::forward_iterator_tag; + using value_type = isc::dns::AbstractRRset const; + using difference_type = std::ptrdiff_t; + using pointer = isc::dns::AbstractRRset const*; + using reference = isc::dns::AbstractRRset const&; + explicit Iterator(IterPtr iter) : iter_(iter) {} @@ -207,7 +212,3 @@ typedef boost::shared_ptr RRsetCollectionPtr; } // end of namespace isc #endif // RRSET_COLLECTION_BASE_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/encode/base_n.cc b/src/lib/util/encode/base_n.cc index eb0eb2358f..e0c37e5f49 100644 --- a/src/lib/util/encode/base_n.cc +++ b/src/lib/util/encode/base_n.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -112,8 +112,15 @@ const uint8_t BINARY_ZERO_CODE = 0; // Note: this class is intended to be used within this implementation file, // and assumes "base < base_end" on construction without validating the // arguments. The behavior is undefined if this assumption doesn't hold. -class EncodeNormalizer : public iterator { +class EncodeNormalizer { public: + // Aliases used to enable iterator behavior on this class + using iterator_category = input_iterator_tag; + using value_type = uint8_t; + using difference_type = ptrdiff_t; + using pointer = uint8_t*; + using reference = uint8_t&; + EncodeNormalizer(const vector::const_iterator& base, const vector::const_iterator& base_end) : base_(base), base_end_(base_end), in_pad_(false) @@ -167,8 +174,15 @@ private: // and for simplicity assumes "base < base_beginpad <= base_end" on // construction without validating the arguments. The behavior is undefined // if this assumption doesn't hold. -class DecodeNormalizer : public iterator { +class DecodeNormalizer { public: + // Aliases used to enable iterator behavior on this class + using iterator_category = input_iterator_tag; + using value_type = char; + using difference_type = ptrdiff_t; + using pointer = char*; + using reference = char&; + DecodeNormalizer(const char base_zero_code, const string::const_iterator& base, const string::const_iterator& base_beginpad,