]> OCCT Git - occt.git/commitdiff
0032906: Coding Rules - get rid of std::iterator inheritance (deprecated since C...
authorddzama <ddzama@opencascade.com>
Wed, 30 Mar 2022 06:24:49 +0000 (09:24 +0300)
committersmoskvin <smoskvin@opencascade.com>
Thu, 21 Apr 2022 21:27:47 +0000 (00:27 +0300)
src/NCollection/NCollection_StlIterator.hxx
src/OSD/OSD_Parallel.hxx

index 78fa3cf150f711497425f37f2e6cf58affe2474b..735ba0e862a50db8b429c44d8f5b399ff49fef97 100644 (file)
 //! iterator requires Offset and Differ methods. See NCollection_Vector as
 //! example of declaring custom STL iterators.
 template<class Category, class BaseIterator, class ItemType, bool IsConstant>
-class NCollection_StlIterator :
-  public std::iterator<Category, ItemType, ptrdiff_t,
-                       typename std::conditional<IsConstant, const ItemType*, ItemType*>::type,
-                       typename std::conditional<IsConstant, const ItemType&, ItemType&>::type>
+class NCollection_StlIterator
 {
 public:
 
+  // Since C++20 inheritance from std::iterator is deprecated, so define predefined types manually:
+  using iterator_category = Category;
+  using value_type = ItemType;
+  using difference_type = ptrdiff_t;
+  using pointer = typename std::conditional<IsConstant, const ItemType*, ItemType*>::type;
+  using reference = typename std::conditional<IsConstant, const ItemType&, ItemType&>::type;
+
   //! Default constructor
   NCollection_StlIterator () {}
 
index b3dd8d0d47dd7bedd4c63389e3f6c079813c3010..2dab32050f7648d9d084ab49a3d628d913d7585f 100644 (file)
@@ -118,12 +118,19 @@ protected:
   //! iteration over objects subject to parallel processing.
   //! It stores pointer to instance of polymorphic iterator inheriting from 
   //! IteratorInterface, which contains actual type-specific iterator.
-  class UniversalIterator : 
+  class UniversalIterator
     // Note that TBB requires that value_type of iterator be copyable, 
     // thus we use its own type for that
-    public std::iterator<std::forward_iterator_tag, UniversalIterator, ptrdiff_t, UniversalIterator*, UniversalIterator&>
   {
   public:
+
+    // Since C++20 inheritance from std::iterator is deprecated, so define predefined types manually:
+    using iterator_category = std::forward_iterator_tag;
+    using value_type = UniversalIterator;
+    using difference_type = ptrdiff_t;
+    using pointer = UniversalIterator*;
+    using reference = UniversalIterator&;
+
     UniversalIterator() {}
 
     UniversalIterator(IteratorInterface* theOther)