]> OCCT Git - occt.git/commitdiff
Foundation Classes, NCollection - Modernize code, add noexcept/constexpr (#793)
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Sat, 1 Nov 2025 21:38:48 +0000 (21:38 +0000)
committerGitHub <noreply@github.com>
Sat, 1 Nov 2025 21:38:48 +0000 (21:38 +0000)
- Mark many methods and operators noexcept (iterators, containers, allocators, maps, lists, buffers, UTF/string utilities, etc.)
- Add constexpr to suitable functions and factory methods (matrices, vectors, static sizes) to enable compile-time usage
- Replace non-constexpr memcpy usages in NCollection_Mat3/NCollection_Mat4 with constexpr-friendly initialization and promote static arrays to constexpr
- Make several small API improvements: stronger const-correctness, noexcept on allocation/deallocation operators, delete forbidden copy ctors/assign where appropriate
- Remove obsolete NCollection_TypeDef.hxx and update FILES.cmake
- Miscellaneous small refactors to support modern C++ patterns and better compile-time guarantees

63 files changed:
src/FoundationClasses/TKMath/Poly/Poly_CoherentLink.hxx
src/FoundationClasses/TKMath/Poly/Poly_CoherentNode.hxx
src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangle.hxx
src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangulation.cxx
src/FoundationClasses/TKMath/Poly/Poly_CoherentTriangulation.hxx
src/FoundationClasses/TKernel/NCollection/FILES.cmake
src/FoundationClasses/TKernel/NCollection/NCollection_AccAllocator.cxx
src/FoundationClasses/TKernel/NCollection/NCollection_AccAllocator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_AlignedAllocator.cxx
src/FoundationClasses/TKernel/NCollection/NCollection_AlignedAllocator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Allocator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_BaseAllocator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_BaseList.cxx
src/FoundationClasses/TKernel/NCollection/NCollection_BaseList.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_BaseMap.cxx
src/FoundationClasses/TKernel/NCollection/NCollection_BaseMap.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_BasePointerVector.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_BaseSequence.cxx
src/FoundationClasses/TKernel/NCollection/NCollection_BaseSequence.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Buffer.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_CellFilter.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_DataMap.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_DefineHArray1.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_DefineHArray2.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_DefineHSequence.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_DoubleMap.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_DynamicArray.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_EBTree.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Handle.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_IndexedDataMap.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_IndexedIterator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_IndexedMap.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Iterator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_List.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_ListNode.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_LocalArray.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Map.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Mat3.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Mat4.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_OccAllocator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Primes.cxx
src/FoundationClasses/TKernel/NCollection/NCollection_Primes.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Sequence.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_SparseArray.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_SparseArrayBase.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_StlIterator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_TListIterator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_TListNode.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_TypeDef.hxx [deleted file]
src/FoundationClasses/TKernel/NCollection/NCollection_UBTree.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_UBTreeFiller.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_UtfIterator.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_UtfIterator.lxx
src/FoundationClasses/TKernel/NCollection/NCollection_UtfString.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_UtfString.lxx
src/FoundationClasses/TKernel/NCollection/NCollection_Vec2.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Vec3.hxx
src/FoundationClasses/TKernel/NCollection/NCollection_Vec4.hxx
src/FoundationClasses/TKernel/Standard/Standard_DefineAlloc.hxx
src/Visualization/TKOpenGl/OpenGl/OpenGl_View_Raytrace.cxx
src/Visualization/TKV3d/SelectMgr/SelectMgr_ViewerSelector.cxx

index 15b7eb5051ae440bddc186109192a93764e47c77..21e0665738907b5bce0ebe5309a3a09be968e042 100644 (file)
@@ -101,7 +101,7 @@ public:
    * Query the status of the link - if it is an invalid one.
    * An invalid link has Node members equal to -1.
    */
-  inline Standard_Boolean IsEmpty() const { return myNode[0] < 0 || myNode[1] < 0; }
+  inline Standard_Boolean IsEmpty() const noexcept { return myNode[0] < 0 || myNode[1] < 0; }
 
   /**
    * Invalidate this Link.
index 3db8e5fcabec9cafcdc64e57ce1c9a304250c4b8..e7170226b3a358d9e5eacd3ed2bd8a965ce3f4e1 100644 (file)
@@ -117,7 +117,7 @@ public:
    * Check if this is a free node, i.e., a node without a single
    * incident triangle.
    */
-  inline Standard_Boolean IsFreeNode() const { return myTriangles == 0L; }
+  inline Standard_Boolean IsFreeNode() const noexcept { return myTriangles == 0L; }
 
   /**
    * Reset the Node to void.
index ffad2f33a711b2d9e4fe49428d8f5236284d1cb0..447afcf7b64b5588c566e332ae66fd8bb63c1b43 100644 (file)
@@ -57,7 +57,7 @@ public:
   /**
    * Query if this is a valid triangle.
    */
-  inline Standard_Boolean IsEmpty() const
+  inline Standard_Boolean IsEmpty() const noexcept
   {
     return myNodes[0] < 0 || myNodes[1] < 0 || myNodes[2] < 0;
   }
index 52449c71e640dcfbd923e022fe816116e0b49c0a..049ba194f17d10765817cbadb5c936072177b7e3 100644 (file)
@@ -277,7 +277,7 @@ Poly_CoherentTriangulation::IteratorOfTriangle::IteratorOfTriangle(
 
 //=================================================================================================
 
-void Poly_CoherentTriangulation::IteratorOfTriangle::Next()
+void Poly_CoherentTriangulation::IteratorOfTriangle::Next() noexcept
 {
   Poly_BaseIteratorOfCoherentTriangle::Next();
   while (More())
@@ -308,7 +308,7 @@ Poly_CoherentTriangulation::IteratorOfNode::IteratorOfNode(
 
 //=================================================================================================
 
-void Poly_CoherentTriangulation::IteratorOfNode::Next()
+void Poly_CoherentTriangulation::IteratorOfNode::Next() noexcept
 {
   Poly_BaseIteratorOfCoherentNode::Next();
   while (More())
@@ -338,7 +338,7 @@ Poly_CoherentTriangulation::IteratorOfLink::IteratorOfLink(
 
 //=================================================================================================
 
-void Poly_CoherentTriangulation::IteratorOfLink::Next()
+void Poly_CoherentTriangulation::IteratorOfLink::Next() noexcept
 {
   Poly_BaseIteratorOfCoherentLink::Next();
   while (More())
index c8fcadb4e92a0fee987ce0e5fbf2df13c87461d3..fbbe798e4c99495018417e53dc63b6c0c4e63ded 100644 (file)
@@ -115,7 +115,7 @@ public:
     //! Constructor
     Standard_EXPORT IteratorOfTriangle(const Handle(Poly_CoherentTriangulation)& theTri);
     //! Make step
-    Standard_EXPORT virtual void Next();
+    Standard_EXPORT virtual void Next() noexcept;
   };
 
   /**
@@ -127,7 +127,7 @@ public:
     //! Constructor
     Standard_EXPORT IteratorOfNode(const Handle(Poly_CoherentTriangulation)& theTri);
     //! Make step
-    Standard_EXPORT virtual void Next();
+    Standard_EXPORT virtual void Next() noexcept;
   };
 
   /**
@@ -139,7 +139,7 @@ public:
     //! Constructor
     Standard_EXPORT IteratorOfLink(const Handle(Poly_CoherentTriangulation)& theTri);
     //! Make step
-    Standard_EXPORT virtual void Next();
+    Standard_EXPORT virtual void Next() noexcept;
   };
 
   //! Couple of integer indices (used in RemoveDegenerated()).
index 42f4f77310f2bef952908cfbf29a7cb87c223f80..485bda5d2790e88f4dc8ade714962ac4bd9d2e39 100644 (file)
@@ -65,7 +65,6 @@ set(OCCT_NCollection_FILES
   NCollection_String.hxx
   NCollection_TListIterator.hxx
   NCollection_TListNode.hxx
-  NCollection_TypeDef.hxx
   NCollection_UBTree.hxx
   NCollection_UBTreeFiller.hxx
   NCollection_UtfIterator.hxx
index 877b8aaa2e468dbe5d47c31acaac9265ae40e53f..774eb5053fc7cf7f686f97a1f977954b3ec7f15e 100644 (file)
@@ -159,7 +159,7 @@ void NCollection_AccAllocator::Free(void* theAddress)
 //=======================================================================
 NCollection_AccAllocator::Block* NCollection_AccAllocator::findBlock(
   const Standard_Address theAddress,
-  Key&                   theKey)
+  Key&                   theKey) noexcept
 {
   theKey = getKey(theAddress);
 
index 8eb0a2282f42fdd66b37c3fb783c9dc6f50b07e8..0a371beef77f91d4c1d4c86dfdfce7d86bfdb97d 100644 (file)
@@ -43,13 +43,13 @@ class NCollection_AccAllocator : public NCollection_BaseAllocator
   // --------- PUBLIC CONSTANTS ---------
 public:
   //! Alignment of all allocated objects: 4 bytes
-  static const Standard_Size Align = 4;
+  static constexpr Standard_Size Align = 4;
 
   //! Default block size
-  static const Standard_Size DefaultBlockSize = 24600;
+  static constexpr Standard_Size DefaultBlockSize = 24600;
 
   //! Number of last blocks to check for free space
-  static const Standard_Integer MaxLookupBlocks = 16;
+  static constexpr Standard_Integer MaxLookupBlocks = 16;
 
   // ---------- PUBLIC METHODS ----------
 public:
@@ -77,17 +77,17 @@ protected:
     Standard_Size myValue;
 
   public:
-    AlignedSize()
+    constexpr AlignedSize() noexcept
         : myValue(0)
     {
     }
 
-    AlignedSize(const Standard_Size theValue)
+    constexpr AlignedSize(const Standard_Size theValue) noexcept
         : myValue((theValue + Align - 1) & ~(Align - 1))
     {
     }
 
-    operator Standard_Size() const { return myValue; }
+    constexpr operator Standard_Size() const noexcept { return myValue; }
   };
 
   //! A pointer aligned to a 4 byte boundary
@@ -96,27 +96,27 @@ protected:
     Standard_Byte* myValue;
 
   public:
-    AlignedPtr()
+    constexpr AlignedPtr() noexcept
         : myValue(0)
     {
     }
 
-    AlignedPtr(const Standard_Address theValue)
+    AlignedPtr(const Standard_Address theValue) noexcept
         : myValue((Standard_Byte*)((Standard_Size)theValue & ~(Align - 1)))
     {
     }
 
-    operator Standard_Address() const { return myValue; }
+    operator Standard_Address() const noexcept { return myValue; }
 
-    operator Standard_Byte*() const { return myValue; }
+    operator Standard_Byte*() const noexcept { return myValue; }
 
-    AlignedPtr operator-(const AlignedSize theValue) const { return myValue - theValue; }
+    AlignedPtr operator-(const AlignedSize theValue) const noexcept { return myValue - theValue; }
 
-    AlignedPtr operator+(const AlignedSize theValue) const { return myValue + theValue; }
+    AlignedPtr operator+(const AlignedSize theValue) const noexcept { return myValue + theValue; }
 
-    AlignedPtr operator-=(const AlignedSize theValue) { return myValue -= theValue; }
+    AlignedPtr operator-=(const AlignedSize theValue) noexcept { return myValue -= theValue; }
 
-    AlignedPtr operator+=(const AlignedSize theValue) { return myValue += theValue; }
+    AlignedPtr operator+=(const AlignedSize theValue) noexcept { return myValue += theValue; }
   };
 
   //! A key for the map of blocks
@@ -148,7 +148,9 @@ protected:
     Block*           prevBlock;
     Standard_Integer allocCount;
 
-    Block(const Standard_Address theAddress, const Standard_Size theSize, Block* thePrevBlock = 0L)
+    Block(const Standard_Address theAddress,
+          const Standard_Size    theSize,
+          Block*                 thePrevBlock = 0L) noexcept
         : address(theAddress),
           prevBlock(thePrevBlock),
           allocCount(0)
@@ -156,14 +158,17 @@ protected:
       SetFreeSize(theSize);
     }
 
-    void SetFreeSize(const Standard_Size theSize)
+    void SetFreeSize(const Standard_Size theSize) noexcept
     {
       allocStart = (Standard_Byte*)address + theSize;
     }
 
-    Standard_Size FreeSize() const { return (Standard_Byte*)allocStart - (Standard_Byte*)address; }
+    Standard_Size FreeSize() const noexcept
+    {
+      return (Standard_Byte*)allocStart - (Standard_Byte*)address;
+    }
 
-    AlignedPtr Allocate(const AlignedSize theSize)
+    AlignedPtr Allocate(const AlignedSize theSize) noexcept
     {
       allocCount++;
       return allocStart -= theSize;
@@ -171,28 +176,28 @@ protected:
 
     void Free() { allocCount--; }
 
-    Standard_Boolean IsEmpty() const { return allocCount == 0; }
+    Standard_Boolean IsEmpty() const noexcept { return allocCount == 0; }
   };
 
   // --------- PROTECTED METHODS ---------
 protected:
   //! Calculate a key for the data map basing on the given address
-  inline Key getKey(const Standard_Address theAddress) const
+  inline Key getKey(const Standard_Address theAddress) const noexcept
   {
     Key aKey = {(Standard_Size)theAddress / myBlockSize};
     return aKey;
   }
 
   //! Find a block that the given allocation unit belongs to
-  Standard_EXPORT Block* findBlock(const Standard_Address theAddress, Key& theKey);
+  Standard_EXPORT Block* findBlock(const Standard_Address theAddress, Key& theKey) noexcept;
 
   //! Allocate a new block and return a pointer to it
   Standard_EXPORT Block* allocateNewBlock(const Standard_Size theSize);
 
   // --------- PROHIBITED METHODS ---------
 private:
-  NCollection_AccAllocator(const NCollection_AccAllocator&);
-  NCollection_AccAllocator& operator=(const NCollection_AccAllocator&);
+  NCollection_AccAllocator(const NCollection_AccAllocator&)            = delete;
+  NCollection_AccAllocator& operator=(const NCollection_AccAllocator&) = delete;
 
   // --------- PROTECTED DATA ---------
 protected:
index 35795a5c317840311b4b5a43ffc7dac16e9c4b6b..a336c267d2ea2ef26de534cc85abe70035b856cf 100644 (file)
@@ -20,7 +20,7 @@ IMPLEMENT_STANDARD_RTTIEXT(NCollection_AlignedAllocator, NCollection_BaseAllocat
 
 //=================================================================================================
 
-NCollection_AlignedAllocator::NCollection_AlignedAllocator(const size_t theAlignment)
+NCollection_AlignedAllocator::NCollection_AlignedAllocator(const size_t theAlignment) noexcept
     : myAlignment(theAlignment)
 {
   //
index 6178e64372cb61ae169b4aed240096afbe094454..f154698ce88ccc623ca4390f1ad7048a825bcd11 100644 (file)
@@ -26,7 +26,7 @@ public:
   //! Constructor. The alignment should be specified explicitly:
   //! 16 bytes for SSE instructions
   //! 32 bytes for AVX instructions
-  Standard_EXPORT NCollection_AlignedAllocator(const size_t theAlignment);
+  Standard_EXPORT NCollection_AlignedAllocator(const size_t theAlignment) noexcept;
 
   //! Allocate memory with given size. Returns NULL on failure.
   Standard_EXPORT virtual void* Allocate(const size_t theSize) Standard_OVERRIDE;
@@ -38,8 +38,8 @@ public:
   Standard_EXPORT virtual void Free(void* thePtr) Standard_OVERRIDE;
 
 private:
-  NCollection_AlignedAllocator(const NCollection_AlignedAllocator&);
-  NCollection_AlignedAllocator& operator=(const NCollection_AlignedAllocator&);
+  NCollection_AlignedAllocator(const NCollection_AlignedAllocator&)            = delete;
+  NCollection_AlignedAllocator& operator=(const NCollection_AlignedAllocator&) = delete;
 
 protected:
   size_t myAlignment; //!< alignment in bytes
index 8b5e8949f51a432dbee4e3dc62fb1591a3b67474..cd92eda7db2e010d7532b31806c6eb4c6756f952 100644 (file)
@@ -17,6 +17,7 @@
 #include <Standard.hxx>
 #include <NCollection_BaseAllocator.hxx>
 
+#include <type_traits>
 #include <utility>
 
 //! Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5.
@@ -74,10 +75,10 @@ public:
   }
 
   //! Returns an object address.
-  pointer address(reference theItem) const { return &theItem; }
+  pointer address(reference theItem) const noexcept { return &theItem; }
 
   //! Returns an object address.
-  const_pointer address(const_reference theItem) const { return &theItem; }
+  const_pointer address(const_reference theItem) const noexcept { return &theItem; }
 
   //! Allocates memory for theSize objects.
   pointer allocate(const size_type theSize, const void* /*hint*/ = 0) const
@@ -107,31 +108,31 @@ public:
 
   //! Destroys the object.
   //! Uses the object destructor.
-  void destroy(pointer thePnt)
+  void destroy(pointer thePnt) noexcept(std::is_nothrow_destructible<value_type>::value)
   {
     (void)thePnt;
     thePnt->~value_type();
   }
 
-  bool operator==(const NCollection_Allocator&) const { return true; }
+  constexpr bool operator==(const NCollection_Allocator&) const noexcept { return true; }
 
   template <class U>
-  bool operator==(const NCollection_Allocator<U>&) const noexcept
+  constexpr bool operator==(const NCollection_Allocator<U>&) const noexcept
   {
     return true;
   }
 
-  bool operator!=(const NCollection_Allocator&) const noexcept { return false; }
+  constexpr bool operator!=(const NCollection_Allocator&) const noexcept { return false; }
 
   template <class U>
-  bool operator!=(const NCollection_Allocator<U>&) const noexcept
+  constexpr bool operator!=(const NCollection_Allocator<U>&) const noexcept
   {
     return false;
   }
 };
 
 template <class U, class V>
-bool operator==(const NCollection_Allocator<U>&, const NCollection_Allocator<V>&)
+constexpr bool operator==(const NCollection_Allocator<U>&, const NCollection_Allocator<V>&) noexcept
 {
   return true;
 }
index 374795b087e592fe39b1c05b861ad1b9acf396b7..a5fd812aca9aab1f403f9d1ec21a1fb6c9af9ef9 100644 (file)
@@ -81,21 +81,21 @@ public:
   using Iterator       = NCollection_Iterator<NCollection_Array1<TheItemType>>;
 
 public:
-  const_iterator begin() const { return const_iterator(*this); }
+  const_iterator begin() const noexcept { return const_iterator(*this); }
 
-  iterator begin() { return iterator(*this); }
+  iterator begin() noexcept { return iterator(*this); }
 
-  const_iterator cbegin() const { return const_iterator(*this); }
+  const_iterator cbegin() const noexcept { return const_iterator(*this); }
 
-  iterator end() { return iterator(mySize, *this); }
+  iterator end() noexcept { return iterator(mySize, *this); }
 
-  const_iterator end() const { return const_iterator(mySize, *this); }
+  const_iterator end() const noexcept { return const_iterator(mySize, *this); }
 
-  const_iterator cend() const { return const_iterator(mySize, *this); }
+  const_iterator cend() const noexcept { return const_iterator(mySize, *this); }
 
 public:
   // Constructors
-  NCollection_Array1()
+  NCollection_Array1() noexcept
       : myLowerBound(1),
         mySize(0)
   {
@@ -197,19 +197,19 @@ public:
   }
 
   //! Size query
-  Standard_Integer Size() const { return Length(); }
+  Standard_Integer Size() const noexcept { return Length(); }
 
   //! Length query (the same)
-  Standard_Integer Length() const { return static_cast<Standard_Integer>(mySize); }
+  Standard_Integer Length() const noexcept { return static_cast<Standard_Integer>(mySize); }
 
   //! Return TRUE if array has zero length.
-  Standard_Boolean IsEmpty() const { return mySize == 0; }
+  Standard_Boolean IsEmpty() const noexcept { return mySize == 0; }
 
   //! Lower bound
-  Standard_Integer Lower() const { return myLowerBound; }
+  Standard_Integer Lower() const noexcept { return myLowerBound; }
 
   //! Upper bound
-  Standard_Integer Upper() const { return myLowerBound + static_cast<int>(mySize) - 1; }
+  Standard_Integer Upper() const noexcept { return myLowerBound + static_cast<int>(mySize) - 1; }
 
   //! Copies data of theOther array to this.
   //! This array should be pre-allocated and have the same length as theOther;
@@ -255,7 +255,10 @@ public:
     return *this;
   }
 
-  NCollection_Array1& Move(NCollection_Array1& theOther) { return Move(std::move(theOther)); }
+  NCollection_Array1& Move(NCollection_Array1& theOther) noexcept
+  {
+    return Move(std::move(theOther));
+  }
 
   //! Assignment operator; @sa Assign()
   NCollection_Array1& operator=(const NCollection_Array1& theOther) { return Assign(theOther); }
@@ -267,16 +270,16 @@ public:
   }
 
   //! @return first element
-  const_reference First() const { return myPointer[0]; }
+  const_reference First() const noexcept { return myPointer[0]; }
 
   //! @return first element
-  reference ChangeFirst() { return myPointer[0]; }
+  reference ChangeFirst() noexcept { return myPointer[0]; }
 
   //! @return last element
-  const_reference Last() const { return myPointer[mySize - 1]; }
+  const_reference Last() const noexcept { return myPointer[mySize - 1]; }
 
   //! @return last element
-  reference ChangeLast() { return myPointer[mySize - 1]; }
+  reference ChangeLast() noexcept { return myPointer[mySize - 1]; }
 
   //! Constant value access
   const_reference Value(const Standard_Integer theIndex) const
@@ -323,10 +326,10 @@ public:
   }
 
   //! Changes the lowest bound. Do not move data
-  void UpdateLowerBound(const Standard_Integer theLower) { myLowerBound = theLower; }
+  void UpdateLowerBound(const Standard_Integer theLower) noexcept { myLowerBound = theLower; }
 
   //! Changes the upper bound. Do not move data
-  void UpdateUpperBound(const Standard_Integer theUpper)
+  void UpdateUpperBound(const Standard_Integer theUpper) noexcept
   {
     myLowerBound = myLowerBound - Upper() + theUpper;
   }
@@ -382,7 +385,7 @@ public:
     myIsOwner = true;
   }
 
-  bool IsDeletable() const { return myIsOwner; }
+  bool IsDeletable() const noexcept { return myIsOwner; }
 
   friend iterator;
   friend const_iterator;
index a0089275949ad957c796cb6ff5de40cf00df76f5..b7519be731d239d895d906d7725eed4efc2ad80a 100644 (file)
@@ -67,7 +67,7 @@ public:
   static int BeginPosition(Standard_Integer theRowLower,
                            Standard_Integer /*theRowUpper*/,
                            Standard_Integer theColLower,
-                           Standard_Integer theColUpper)
+                           Standard_Integer theColUpper) noexcept
   {
     // Calculate the offset for the beginning position
     return theColLower + (theRowLower * (theColUpper - theColLower + 1));
@@ -76,7 +76,7 @@ public:
   static int LastPosition(Standard_Integer theRowLower,
                           Standard_Integer theRowUpper,
                           Standard_Integer theColLower,
-                          Standard_Integer theColUpper)
+                          Standard_Integer theColUpper) noexcept
   {
     return ((theRowUpper - theRowLower + 1) * (theColUpper - theColLower + 1)) + theColLower
            + (theRowLower * (theColUpper - theColLower + 1)) - 1;
@@ -87,7 +87,7 @@ public:
 
   //! Empty constructor; should be used with caution.
   //! @sa methods Resize() and Move().
-  NCollection_Array2()
+  NCollection_Array2() noexcept
       : NCollection_Array1<TheItemType>(),
         myLowerRow(1),
         mySizeRow(0),
@@ -170,49 +170,55 @@ public:
   }
 
   //! Size (number of items)
-  Standard_Integer Size() const { return Length(); }
+  Standard_Integer Size() const noexcept { return Length(); }
 
   //! Length (number of items)
-  Standard_Integer Length() const { return NbRows() * NbColumns(); }
+  Standard_Integer Length() const noexcept { return NbRows() * NbColumns(); }
 
   //! Returns number of rows
-  Standard_Integer NbRows() const { return static_cast<int>(mySizeRow); }
+  Standard_Integer NbRows() const noexcept { return static_cast<int>(mySizeRow); }
 
   //! Returns number of columns
-  Standard_Integer NbColumns() const { return static_cast<int>(mySizeCol); }
+  Standard_Integer NbColumns() const noexcept { return static_cast<int>(mySizeCol); }
 
   //! Returns length of the row, i.e. number of columns
-  Standard_Integer RowLength() const { return NbColumns(); }
+  Standard_Integer RowLength() const noexcept { return NbColumns(); }
 
   //! Returns length of the column, i.e. number of rows
-  Standard_Integer ColLength() const { return NbRows(); }
+  Standard_Integer ColLength() const noexcept { return NbRows(); }
 
   //! LowerRow
-  Standard_Integer LowerRow() const { return myLowerRow; }
+  Standard_Integer LowerRow() const noexcept { return myLowerRow; }
 
   //! UpperRow
-  Standard_Integer UpperRow() const { return myLowerRow + static_cast<int>(mySizeRow) - 1; }
+  Standard_Integer UpperRow() const noexcept
+  {
+    return myLowerRow + static_cast<int>(mySizeRow) - 1;
+  }
 
   //! LowerCol
-  Standard_Integer LowerCol() const { return myLowerCol; }
+  Standard_Integer LowerCol() const noexcept { return myLowerCol; }
 
   //! UpperCol
-  Standard_Integer UpperCol() const { return myLowerCol + static_cast<int>(mySizeCol) - 1; }
+  Standard_Integer UpperCol() const noexcept
+  {
+    return myLowerCol + static_cast<int>(mySizeCol) - 1;
+  }
 
   //! Updates lower row
-  void UpdateLowerRow(const Standard_Integer theLowerRow) { myLowerRow = theLowerRow; }
+  void UpdateLowerRow(const Standard_Integer theLowerRow) noexcept { myLowerRow = theLowerRow; }
 
   //! Updates lower column
-  void UpdateLowerCol(const Standard_Integer theLowerCol) { myLowerCol = theLowerCol; }
+  void UpdateLowerCol(const Standard_Integer theLowerCol) noexcept { myLowerCol = theLowerCol; }
 
   //! Updates upper row
-  void UpdateUpperRow(const Standard_Integer theUpperRow)
+  void UpdateUpperRow(const Standard_Integer theUpperRow) noexcept
   {
     myLowerRow = myLowerRow - UpperRow() + theUpperRow;
   }
 
   //! Updates upper column
-  void UpdateUpperCol(const Standard_Integer theUpperCol)
+  void UpdateUpperCol(const Standard_Integer theUpperCol) noexcept
   {
     myLowerCol = myLowerCol - UpperCol() + theUpperCol;
   }
@@ -232,7 +238,7 @@ public:
   //! Move assignment.
   //! This array will borrow all the data from theOther.
   //! The moved object will be left uninitialized and should not be used anymore.
-  NCollection_Array2& Move(NCollection_Array2&& theOther)
+  NCollection_Array2& Move(NCollection_Array2&& theOther) noexcept
   {
     if (&theOther == this)
     {
@@ -253,13 +259,16 @@ public:
   //! Move assignment.
   //! This array will borrow all the data from theOther.
   //! The moved object will be left uninitialized and should not be used anymore.
-  NCollection_Array2& Move(NCollection_Array2& theOther) { return Move(std::move(theOther)); }
+  NCollection_Array2& Move(NCollection_Array2& theOther) noexcept
+  {
+    return Move(std::move(theOther));
+  }
 
   //! Assignment operator
   NCollection_Array2& operator=(const NCollection_Array2& theOther) { return Assign(theOther); }
 
   //! Move assignment operator; @sa Move()
-  NCollection_Array2& operator=(NCollection_Array2&& theOther)
+  NCollection_Array2& operator=(NCollection_Array2&& theOther) noexcept
   {
     return Move(std::forward<NCollection_Array2>(theOther));
   }
index cccc8a97d44e7afa770494536eb1932d46d9287b..35a3d00015b5e18d77baa9768e69dd6e1ae9c230 100644 (file)
@@ -58,7 +58,7 @@ public:
 
 protected:
   //! Constructor - prohibited
-  NCollection_BaseAllocator() {}
+  NCollection_BaseAllocator() noexcept {}
 
 private:
   //! Copy constructor - prohibited
index 202656b0380792386b61b515f2388bc7117c6c9e..cd85811a83faac8e14538c9c89583c32b34b3683 100644 (file)
@@ -41,7 +41,7 @@ void NCollection_BaseList::PClear(NCollection_DelListNode fDel)
 // purpose  : Appends one item at the end
 //=======================================================================
 
-void NCollection_BaseList::PAppend(NCollection_ListNode* theNode)
+void NCollection_BaseList::PAppend(NCollection_ListNode* theNode) noexcept
 {
   if (myLength)
     myLast->Next() = theNode;
@@ -57,7 +57,7 @@ void NCollection_BaseList::PAppend(NCollection_ListNode* theNode)
 // purpose  : Appends another list at the end
 //=======================================================================
 
-void NCollection_BaseList::PAppend(NCollection_BaseList& theOther)
+void NCollection_BaseList::PAppend(NCollection_BaseList& theOther) noexcept
 {
   if (this == &theOther || theOther.IsEmpty())
     return;
@@ -78,7 +78,7 @@ void NCollection_BaseList::PAppend(NCollection_BaseList& theOther)
 // purpose  : Prepends one item at the beginning
 //=======================================================================
 
-void NCollection_BaseList::PPrepend(NCollection_ListNode* theNode)
+void NCollection_BaseList::PPrepend(NCollection_ListNode* theNode) noexcept
 {
   theNode->Next() = myFirst;
   myFirst         = theNode;
@@ -89,7 +89,7 @@ void NCollection_BaseList::PPrepend(NCollection_ListNode* theNode)
 
 //=================================================================================================
 
-void NCollection_BaseList::PPrepend(NCollection_BaseList& theOther)
+void NCollection_BaseList::PPrepend(NCollection_BaseList& theOther) noexcept
 {
   if (this == &theOther || theOther.IsEmpty())
     return;
@@ -218,7 +218,7 @@ void NCollection_BaseList::PInsertAfter(NCollection_BaseList& theOther, Iterator
 
 //=================================================================================================
 
-void NCollection_BaseList::PReverse()
+void NCollection_BaseList::PReverse() noexcept
 {
   if (myLength > 1)
   {
index 1f60a12c03801cf1e7c139e1c238930b8f774cbd..77517c151c62882d39696e1b850379470f91c82e 100644 (file)
@@ -45,43 +45,43 @@ public:
   {
   public:
     // ******** Empty constructor
-    Iterator(void)
+    Iterator(void) noexcept
         : myCurrent(NULL),
           myPrevious(NULL)
     {
     }
 
     // ******** Constructor with initialisation
-    Iterator(const NCollection_BaseList& theList)
+    Iterator(const NCollection_BaseList& theList) noexcept
         : myCurrent(theList.myFirst),
           myPrevious(NULL)
     {
     }
 
     // ******** Initialisation
-    void Init(const NCollection_BaseList& theList)
+    void Init(const NCollection_BaseList& theList) noexcept
     {
       myCurrent  = theList.myFirst;
       myPrevious = NULL;
     }
 
     // ******** Initialisation
-    void Initialize(const NCollection_BaseList& theList) { Init(theList); }
+    void Initialize(const NCollection_BaseList& theList) noexcept { Init(theList); }
 
     // ******** More
-    Standard_Boolean More(void) const { return (myCurrent != NULL); }
+    Standard_Boolean More(void) const noexcept { return (myCurrent != NULL); }
 
     // ******** Comparison operator
-    Standard_Boolean operator==(const Iterator& theIt) const
+    Standard_Boolean operator==(const Iterator& theIt) const noexcept
     {
       return myCurrent == theIt.myCurrent;
     }
 
     //! Performs comparison of two iterators
-    Standard_Boolean IsEqual(const Iterator& theOther) const { return *this == theOther; }
+    Standard_Boolean IsEqual(const Iterator& theOther) const noexcept { return *this == theOther; }
 
   protected:
-    void Init(const NCollection_BaseList& theList, NCollection_ListNode* const thePrev)
+    void Init(const NCollection_BaseList& theList, NCollection_ListNode* const thePrev) noexcept
     {
       myCurrent  = thePrev ? thePrev->Next() : (NCollection_ListNode*)theList.PLast();
       myPrevious = thePrev;
@@ -97,15 +97,15 @@ public:
   // ---------- PUBLIC METHODS ------------
   // ******** Extent
   // Purpose: Returns the number of nodes in the list
-  Standard_Integer Extent(void) const { return myLength; }
+  Standard_Integer Extent(void) const noexcept { return myLength; }
 
   // ******** IsEmpty
   // Purpose: Query if the list is empty
-  Standard_Boolean IsEmpty(void) const { return (myFirst == NULL); }
+  Standard_Boolean IsEmpty(void) const noexcept { return (myFirst == NULL); }
 
   // ******** Allocator
   //! Returns attached allocator
-  const Handle(NCollection_BaseAllocator)& Allocator() const { return myAllocator; }
+  const Handle(NCollection_BaseAllocator)& Allocator() const noexcept { return myAllocator; }
 
   // ******** Destructor
   // Purpose: defines virtual interface
@@ -131,19 +131,19 @@ protected:
 
   // ******** PFirst
   // Purpose: Returns pointer to the first node
-  const NCollection_ListNode* PFirst(void) const { return myFirst; }
+  const NCollection_ListNode* PFirst(void) const noexcept { return myFirst; }
 
   // ******** PLast
   // Purpose: Returns pointer to the last node
-  const NCollection_ListNode* PLast(void) const { return myLast; }
+  const NCollection_ListNode* PLast(void) const noexcept { return myLast; }
 
   // ******** PAppend
   // Purpose: Appends theNode at the end
-  Standard_EXPORT void PAppend(NCollection_ListNode* theNode);
+  Standard_EXPORT void PAppend(NCollection_ListNode* theNode) noexcept;
 
   // ******** PAppend
   // Purpose: Appends theNode at the end, returns iterator to the previous
-  void PAppend(NCollection_ListNode* theNode, Iterator& theIt)
+  void PAppend(NCollection_ListNode* theNode, Iterator& theIt) noexcept
   {
     NCollection_ListNode* aPrev = myLast;
     PAppend(theNode);
@@ -152,15 +152,15 @@ protected:
 
   // ******** PAppend
   // Purpose: Appends theOther list at the end (clearing it)
-  Standard_EXPORT void PAppend(NCollection_BaseList& theOther);
+  Standard_EXPORT void PAppend(NCollection_BaseList& theOther) noexcept;
 
   // ******** PPrepend
   // Purpose: Prepends theNode at the beginning
-  Standard_EXPORT void PPrepend(NCollection_ListNode* theNode);
+  Standard_EXPORT void PPrepend(NCollection_ListNode* theNode) noexcept;
 
   // ******** PPrepend
   // Purpose: Prepends theOther list at the beginning (clearing it)
-  Standard_EXPORT void PPrepend(NCollection_BaseList& theOther);
+  Standard_EXPORT void PPrepend(NCollection_BaseList& theOther) noexcept;
 
   // ******** PRemoveFirst
   // Purpose: Removes first node
@@ -188,7 +188,7 @@ protected:
 
   // ******** PReverse
   // Purpose: Reverse the list
-  Standard_EXPORT void PReverse();
+  Standard_EXPORT void PReverse() noexcept;
 
 protected:
   // ------------ PROTECTED FIELDS ------------
index 949d03f791f6e74dc365f7383d67427f9980964f..972d73dff475e30e5cdb4139bd1447c6180a40e6 100644 (file)
@@ -49,7 +49,7 @@ Standard_Boolean NCollection_BaseMap::BeginResize(const Standard_Integer  NbBuck
 void NCollection_BaseMap::EndResize(const Standard_Integer theNbBuckets,
                                     const Standard_Integer N,
                                     NCollection_ListNode** data1,
-                                    NCollection_ListNode** data2)
+                                    NCollection_ListNode** data2) noexcept
 {
   (void)theNbBuckets; // obsolete parameter
   if (myData1)
@@ -152,7 +152,7 @@ void NCollection_BaseMap::Statistics(Standard_OStream& S) const
 
 //=================================================================================================
 
-Standard_Integer NCollection_BaseMap::NextPrimeForMap(const Standard_Integer N) const
+Standard_Integer NCollection_BaseMap::NextPrimeForMap(const Standard_Integer N) const noexcept
 {
   return NCollection_Primes::NextPrimeForMap(N);
 }
index 7d21645ce260d92b8bfe0cf176d3d2fcfce6181c..df4af033e08221ff104a8f632ce98005a28b4b4a 100644 (file)
@@ -47,7 +47,7 @@ public:
   {
   protected:
     //! Empty constructor
-    Iterator(void)
+    Iterator(void) noexcept
         : myNbBuckets(0),
           myBuckets(nullptr),
           myBucket(0),
@@ -56,7 +56,7 @@ public:
     }
 
     //! Constructor
-    Iterator(const NCollection_BaseMap& theMap)
+    Iterator(const NCollection_BaseMap& theMap) noexcept
         : myNbBuckets(theMap.myNbBuckets),
           myBuckets(theMap.myData1),
           myBucket(-1),
@@ -76,7 +76,7 @@ public:
 
   public:
     //! Initialize
-    void Initialize(const NCollection_BaseMap& theMap)
+    void Initialize(const NCollection_BaseMap& theMap) noexcept
     {
       myNbBuckets = theMap.myNbBuckets;
       myBuckets   = theMap.myData1;
@@ -88,7 +88,7 @@ public:
     }
 
     //! Reset
-    void Reset(void)
+    void Reset(void) noexcept
     {
       myBucket = -1;
       myNode   = nullptr;
@@ -96,17 +96,17 @@ public:
     }
 
     //! Performs comparison of two iterators.
-    Standard_Boolean IsEqual(const Iterator& theOther) const
+    Standard_Boolean IsEqual(const Iterator& theOther) const noexcept
     {
       return myBucket == theOther.myBucket && myNode == theOther.myNode;
     }
 
   protected:
     //! PMore
-    Standard_Boolean PMore(void) const { return (myNode != nullptr); }
+    Standard_Boolean PMore(void) const noexcept { return (myNode != nullptr); }
 
     //! PNext
-    void PNext(void)
+    void PNext(void) noexcept
     {
       if (!myBuckets)
         return;
@@ -137,19 +137,19 @@ public:
   // ---------- PUBLIC METHODS ------------
 
   //! NbBuckets
-  Standard_Integer NbBuckets() const { return myNbBuckets; }
+  Standard_Integer NbBuckets() const noexcept { return myNbBuckets; }
 
   //! Extent
-  Standard_Integer Extent() const { return mySize; }
+  Standard_Integer Extent() const noexcept { return mySize; }
 
   //! IsEmpty
-  Standard_Boolean IsEmpty() const { return mySize == 0; }
+  Standard_Boolean IsEmpty() const noexcept { return mySize == 0; }
 
   //! Statistics
   Standard_EXPORT void Statistics(Standard_OStream& S) const;
 
   //! Returns attached allocator
-  const Handle(NCollection_BaseAllocator)& Allocator() const { return myAllocator; }
+  const Handle(NCollection_BaseAllocator)& Allocator() const noexcept { return myAllocator; }
 
 protected:
   // -------- PROTECTED METHODS -----------
@@ -196,26 +196,26 @@ protected:
   Standard_EXPORT void EndResize(const Standard_Integer NbBuckets,
                                  const Standard_Integer NewBuckets,
                                  NCollection_ListNode** data1,
-                                 NCollection_ListNode** data2);
+                                 NCollection_ListNode** data2) noexcept;
 
   //! Resizable
-  Standard_Boolean Resizable() const { return IsEmpty() || (mySize > myNbBuckets); }
+  Standard_Boolean Resizable() const noexcept { return IsEmpty() || (mySize > myNbBuckets); }
 
   //! Increment
-  Standard_Integer Increment() { return ++mySize; }
+  Standard_Integer Increment() noexcept { return ++mySize; }
 
   //! Decrement
-  Standard_Integer Decrement() { return --mySize; }
+  Standard_Integer Decrement() noexcept { return --mySize; }
 
   //! Destroy
   Standard_EXPORT void Destroy(NCollection_DelMapNode fDel,
                                Standard_Boolean       doReleaseMemory = Standard_True);
 
   //! NextPrimeForMap
-  Standard_EXPORT Standard_Integer NextPrimeForMap(const Standard_Integer N) const;
+  Standard_EXPORT Standard_Integer NextPrimeForMap(const Standard_Integer N) const noexcept;
 
   //! Exchange content of two maps without data copying
-  void exchangeMapsData(NCollection_BaseMap& theOther)
+  void exchangeMapsData(NCollection_BaseMap& theOther) noexcept
   {
     std::swap(myAllocator, theOther.myAllocator);
     std::swap(myData1, theOther.myData1);
index 9e10173788a6b94ca5ea911b72c3e62da36213a0..f7bf993861005175a7881ae9107ba6fe96751112 100644 (file)
@@ -35,7 +35,7 @@ public:
 
 public:
   //! Default constructor
-  NCollection_BasePointerVector() {}
+  NCollection_BasePointerVector() noexcept {}
 
   //! Copy data from another vector
   Standard_EXPORT NCollection_BasePointerVector(const NCollection_BasePointerVector& theOther);
@@ -47,16 +47,16 @@ public:
   ~NCollection_BasePointerVector() { clear(); }
 
   //! Checks for an empty status
-  bool IsEmpty() const { return mySize == 0; }
+  bool IsEmpty() const noexcept { return mySize == 0; }
 
   //! Gets used size
-  size_t Size() const { return mySize; }
+  size_t Size() const noexcept { return mySize; }
 
   //! Gets available capacity
-  size_t Capacity() const { return myCapacity; }
+  size_t Capacity() const noexcept { return myCapacity; }
 
   //! Erases last element, decrements size.
-  void RemoveLast() { mySize--; }
+  void RemoveLast() noexcept { mySize--; }
 
   //! Resets the size
   void Clear(const bool theReleaseMemory = false)
@@ -68,10 +68,10 @@ public:
 
 public:
   //! Gets array, can be null
-  void** GetArray() const { return myArray; }
+  void** GetArray() const noexcept { return myArray; }
 
   //! Gets value by index, no access validation
-  void* Value(const size_t theInd) const { return myArray[theInd]; }
+  void* Value(const size_t theInd) const noexcept { return myArray[theInd]; }
 
 public:
   //! Inserts new element at the end, increase size,
index e7d04132473ab0b595d8af7c951d19991e74a93a..3224a781ebd2e42f99a0a6a0194cb2acab1ab20c 100644 (file)
@@ -147,7 +147,7 @@ void NCollection_BaseSequence::PPrepend(NCollection_BaseSequence& Other)
 // purpose  : reverse the order of a given sequence
 //=======================================================================
 
-void NCollection_BaseSequence::PReverse()
+void NCollection_BaseSequence::PReverse() noexcept
 {
   NCollection_SeqNode* p = myFirstItem;
   while (p)
@@ -444,7 +444,7 @@ void NCollection_BaseSequence::RemoveSeq(const Standard_Integer From,
 
 //=================================================================================================
 
-NCollection_SeqNode* NCollection_BaseSequence::Find(const Standard_Integer theIndex) const
+NCollection_SeqNode* NCollection_BaseSequence::Find(const Standard_Integer theIndex) const noexcept
 {
   Standard_Integer     i;
   NCollection_SeqNode* p;
index e6cb3bc6ce0f2e3c2a4ff1ee6a784f52a93ea023..818c3a36d5e6f66aa28f5ff5cb3ae86b64d55d7d 100644 (file)
@@ -28,19 +28,19 @@ public:
   // define new operator for use with NCollection allocators
   DEFINE_NCOLLECTION_ALLOC
 public:
-  NCollection_SeqNode()
+  NCollection_SeqNode() noexcept
       : myNext(NULL),
         myPrevious(NULL)
   {
   }
 
-  NCollection_SeqNode* Next() const { return myNext; }
+  NCollection_SeqNode* Next() const noexcept { return myNext; }
 
-  NCollection_SeqNode* Previous() const { return myPrevious; }
+  NCollection_SeqNode* Previous() const noexcept { return myPrevious; }
 
-  void SetNext(NCollection_SeqNode* theNext) { myNext = theNext; }
+  void SetNext(NCollection_SeqNode* theNext) noexcept { myNext = theNext; }
 
-  void SetPrevious(NCollection_SeqNode* thePrev) { myPrevious = thePrev; }
+  void SetPrevious(NCollection_SeqNode* thePrev) noexcept { myPrevious = thePrev; }
 
 private:
   NCollection_SeqNode* myNext;
@@ -66,28 +66,28 @@ public:
   {
   public:
     //! Empty constructor
-    Iterator(void)
+    Iterator(void) noexcept
         : myCurrent(NULL),
           myPrevious(NULL)
     {
     }
 
     //! Constructor with initialisation
-    Iterator(const NCollection_BaseSequence& theSeq, const Standard_Boolean isStart)
+    Iterator(const NCollection_BaseSequence& theSeq, const Standard_Boolean isStart) noexcept
     {
       Init(theSeq, isStart);
     }
 
     //! Initialisation
     void Init(const NCollection_BaseSequence& theSeq,
-              const Standard_Boolean          isStart = Standard_True)
+              const Standard_Boolean          isStart = Standard_True) noexcept
     {
       myCurrent  = (isStart ? theSeq.myFirstItem : NULL);
       myPrevious = (isStart ? NULL : theSeq.myLastItem);
     }
 
     //! Switch to previous element; note that it will reset
-    void Previous()
+    void Previous() noexcept
     {
       myCurrent = myPrevious;
       if (myCurrent)
@@ -103,12 +103,12 @@ public:
 public:
   // Methods PUBLIC
   //
-  Standard_Boolean IsEmpty() const { return (mySize == 0); }
+  Standard_Boolean IsEmpty() const noexcept { return (mySize == 0); }
 
-  Standard_Integer Length() const { return mySize; }
+  Standard_Integer Length() const noexcept { return mySize; }
 
   //! Returns attached allocator
-  const Handle(NCollection_BaseAllocator)& Allocator() const { return myAllocator; }
+  const Handle(NCollection_BaseAllocator)& Allocator() const noexcept { return myAllocator; }
 
 protected:
   // Methods PROTECTED
@@ -141,9 +141,9 @@ protected:
   Standard_EXPORT void RemoveSeq(const Standard_Integer From,
                                  const Standard_Integer To,
                                  NCollection_DelSeqNode fDel);
-  Standard_EXPORT void PReverse();
+  Standard_EXPORT void PReverse() noexcept;
   Standard_EXPORT void PExchange(const Standard_Integer I, const Standard_Integer J);
-  Standard_EXPORT NCollection_SeqNode* Find(const Standard_Integer) const;
+  Standard_EXPORT NCollection_SeqNode* Find(const Standard_Integer) const noexcept;
 
 protected:
   // Fields PROTECTED
@@ -160,7 +160,7 @@ private:
   //
   Standard_EXPORT NCollection_BaseSequence(const NCollection_BaseSequence& Other);
 
-  void Nullify()
+  void Nullify() noexcept
   {
     myFirstItem = myLastItem = myCurrentItem = NULL;
     myCurrentIndex = mySize = 0;
index 24c85064f44465e888cf7ff3c0f15e3bd53cc069..d42d56f28017892b7a1927cf90d4fcc0206ae76c 100644 (file)
@@ -51,19 +51,19 @@ public:
   ~NCollection_Buffer() { Free(); }
 
   //! @return buffer data
-  const Standard_Byte* Data() const { return myData; }
+  const Standard_Byte* Data() const noexcept { return myData; }
 
   //! @return buffer data
-  Standard_Byte* ChangeData() { return myData; }
+  Standard_Byte* ChangeData() noexcept { return myData; }
 
   //! @return true if buffer is not allocated
-  bool IsEmpty() const { return myData == NULL; }
+  bool IsEmpty() const noexcept { return myData == NULL; }
 
   //! Return buffer length in bytes.
-  Standard_Size Size() const { return mySize; }
+  Standard_Size Size() const noexcept { return mySize; }
 
   //! @return buffer allocator
-  const Handle(NCollection_BaseAllocator)& Allocator() const { return myAllocator; }
+  const Handle(NCollection_BaseAllocator)& Allocator() const noexcept { return myAllocator; }
 
   //! Assign new buffer allocator with de-allocation of buffer.
   void SetAllocator(const Handle(NCollection_BaseAllocator)& theAlloc)
index a8061e2d9e93514d15708ab8a29305d461d4f2b0..c2379d0d4f4ff7333a236ab2eaa988245dd0a66c 100644 (file)
@@ -283,7 +283,7 @@ protected:
     }
 
     //! Assignment operator: ensure that list is not deleted twice
-    void operator=(const Cell& theOther)
+    void operator=(const Cell& theOther) noexcept
     {
       Standard_Integer aDim = Standard_Integer(theOther.index.Size());
       for (Standard_Integer anIdx = 0; anIdx < aDim; anIdx++)
@@ -303,7 +303,7 @@ protected:
     }
 
     //! Compare cell with other one
-    Standard_Boolean IsEqual(const Cell& theOther) const
+    Standard_Boolean IsEqual(const Cell& theOther) const noexcept
     {
       Standard_Integer aDim = Standard_Integer(theOther.index.Size());
       for (int i = 0; i < aDim; i++)
@@ -312,7 +312,7 @@ protected:
       return Standard_True;
     }
 
-    bool operator==(const Cell& theOther) const { return IsEqual(theOther); }
+    bool operator==(const Cell& theOther) const noexcept { return IsEqual(theOther); }
 
   public:
     NCollection_LocalArray<Cell_IndexType, 10> index;
index ee3b2c6ce8bdc730ee48b306aa6cc9d76b079649..b6484f0f473f4de543304e3214e7d4d2355f0bcb 100644 (file)
@@ -88,10 +88,11 @@ public:
     }
 
     //! Key
-    const TheKeyType& Key(void) const { return myKey; }
+    const TheKeyType& Key(void) const noexcept { return myKey; }
 
     //! Static deleter to be passed to BaseMap
-    static void delNode(NCollection_ListNode* theNode, Handle(NCollection_BaseAllocator)& theAl)
+    static void delNode(NCollection_ListNode*              theNode,
+                        Handle(NCollection_BaseAllocator)& theAl) noexcept
     {
       ((DataMapNode*)theNode)->~DataMapNode();
       theAl->Free(theNode);
@@ -119,10 +120,10 @@ public:
     }
 
     //! Query if the end of collection is reached by iterator
-    Standard_Boolean More(void) const { return PMore(); }
+    Standard_Boolean More(void) const noexcept { return PMore(); }
 
     //! Make a step along the collection
-    void Next(void) { PNext(); }
+    void Next(void) noexcept { PNext(); }
 
     //! Value inquiry
     const TheItemType& Value(void) const
@@ -154,16 +155,16 @@ public:
     const_iterator;
 
   //! Returns an iterator pointing to the first element in the map.
-  iterator begin() const { return Iterator(*this); }
+  iterator begin() const noexcept { return Iterator(*this); }
 
   //! Returns an iterator referring to the past-the-end element in the map.
-  iterator end() const { return Iterator(); }
+  iterator end() const noexcept { return Iterator(); }
 
   //! Returns a const iterator pointing to the first element in the map.
-  const_iterator cbegin() const { return Iterator(*this); }
+  const_iterator cbegin() const noexcept { return Iterator(*this); }
 
   //! Returns a const iterator referring to the past-the-end element in the map.
-  const_iterator cend() const { return Iterator(); }
+  const_iterator cend() const noexcept { return Iterator(); }
 
 public:
   // ---------- PUBLIC METHODS ------------
@@ -201,7 +202,7 @@ public:
 
   //! Exchange the content of two maps without re-allocations.
   //! Notice that allocators will be swapped as well!
-  void Exchange(NCollection_DataMap& theOther) { this->exchangeMapsData(theOther); }
+  void Exchange(NCollection_DataMap& theOther) noexcept { this->exchangeMapsData(theOther); }
 
   //! Assignment.
   //! This method does not change the internal allocator.
@@ -552,7 +553,7 @@ public:
   virtual ~NCollection_DataMap(void) { Clear(true); }
 
   //! Size
-  Standard_Integer Size(void) const { return Extent(); }
+  Standard_Integer Size(void) const noexcept { return Extent(); }
 
 protected:
   //! Lookup for particular key in map.
index b406d04f140fded3d2a1ae94b3ff234d7093b799..ef187c5bb5c27938fc48da288c8a40e6aecbf2bf 100644 (file)
         : _Array1Type_(theOther)                                                                   \
     {                                                                                              \
     }                                                                                              \
-    const _Array1Type_& Array1() const                                                             \
+    const _Array1Type_& Array1() const noexcept                                                    \
     {                                                                                              \
       return *this;                                                                                \
     }                                                                                              \
-    _Array1Type_& ChangeArray1()                                                                   \
+    _Array1Type_& ChangeArray1() noexcept                                                          \
     {                                                                                              \
       return *this;                                                                                \
     }                                                                                              \
index 85b7d9a34ab7311abd6ee6d2743f8d3aeb4d13a7..4e7fd3ab21961293c16ca0834def2eabfcfa115d 100644 (file)
         : _Array2Type_(theOther)                                                                   \
     {                                                                                              \
     }                                                                                              \
-    const _Array2Type_& Array2() const                                                             \
+    const _Array2Type_& Array2() const noexcept                                                    \
     {                                                                                              \
       return *this;                                                                                \
     }                                                                                              \
-    _Array2Type_& ChangeArray2()                                                                   \
+    _Array2Type_& ChangeArray2() noexcept                                                          \
     {                                                                                              \
       return *this;                                                                                \
     }                                                                                              \
index a2534bfbc6607c54fb04b3c281ac20aa288cad7c..d3aeea824eb4c13ef5a6fbe861e44c3f7d45e7d5 100644 (file)
@@ -34,7 +34,7 @@
         : _SequenceType_(theOther)                                                                 \
     {                                                                                              \
     }                                                                                              \
-    const _SequenceType_& Sequence() const                                                         \
+    const _SequenceType_& Sequence() const noexcept                                                \
     {                                                                                              \
       return *this;                                                                                \
     }                                                                                              \
@@ -46,7 +46,7 @@
     {                                                                                              \
       _SequenceType_::Append(theSequence);                                                         \
     }                                                                                              \
-    _SequenceType_& ChangeSequence()                                                               \
+    _SequenceType_& ChangeSequence() noexcept                                                      \
     {                                                                                              \
       return *this;                                                                                \
     }                                                                                              \
index 1d5e0e0dd0ebf13cdfb82b3f91f0ffdf78c0c15d..18df51e320f8a5ebdaa4205bbfbe05d190d86aa8 100644 (file)
@@ -60,16 +60,17 @@ public:
     }
 
     //! Key1
-    const TheKey1Type& Key1(void) { return myKey1; }
+    const TheKey1Type& Key1(void) noexcept { return myKey1; }
 
     //! Key2
-    const TheKey2Type& Key2(void) { return this->myValue; }
+    const TheKey2Type& Key2(void) noexcept { return this->myValue; }
 
     //! Next2
-    DoubleMapNode*& Next2(void) { return myNext2; }
+    DoubleMapNode*& Next2(void) noexcept { return myNext2; }
 
     //! Static deleter to be passed to BaseList
-    static void delNode(NCollection_ListNode* theNode, Handle(NCollection_BaseAllocator)& theAl)
+    static void delNode(NCollection_ListNode*              theNode,
+                        Handle(NCollection_BaseAllocator)& theAl) noexcept
     {
       ((DoubleMapNode*)theNode)->~DoubleMapNode();
       theAl->Free(theNode);
@@ -95,10 +96,10 @@ public:
     }
 
     //! Query if the end of collection is reached by iterator
-    Standard_Boolean More(void) const { return PMore(); }
+    Standard_Boolean More(void) const noexcept { return PMore(); }
 
     //! Make a step along the collection
-    void Next(void) { PNext(); }
+    void Next(void) noexcept { PNext(); }
 
     //! Key1 inquiry
     const TheKey1Type& Key1(void) const
@@ -147,7 +148,7 @@ public:
 
   //! Exchange the content of two maps without re-allocations.
   //! Notice that allocators will be swapped as well!
-  void Exchange(NCollection_DoubleMap& theOther) { this->exchangeMapsData(theOther); }
+  void Exchange(NCollection_DoubleMap& theOther) noexcept { this->exchangeMapsData(theOther); }
 
   //! Assignment.
   //! This method does not change the internal allocator.
@@ -507,7 +508,7 @@ public:
   ~NCollection_DoubleMap(void) { Clear(true); }
 
   //! Size
-  Standard_Integer Size(void) const { return Extent(); }
+  Standard_Integer Size(void) const noexcept { return Extent(); }
 
 protected:
   bool IsEqual1(const TheKey1Type& theKey1, const TheKey1Type& theKey2) const
index cc82331ad412456656fe606936a629f26c080937..23e0a2f7619a551942712bbefa671c3711294696 100644 (file)
@@ -84,17 +84,17 @@ public:
   using Iterator       = NCollection_Iterator<NCollection_DynamicArray<TheItemType>>;
 
 public:
-  const_iterator begin() const { return const_iterator(*this); }
+  const_iterator begin() const noexcept { return const_iterator(*this); }
 
-  iterator begin() { return iterator(*this); }
+  iterator begin() noexcept { return iterator(*this); }
 
-  const_iterator cbegin() const { return const_iterator(*this); }
+  const_iterator cbegin() const noexcept { return const_iterator(*this); }
 
-  iterator end() { return iterator(myUsedSize, *this); }
+  iterator end() noexcept { return iterator(myUsedSize, *this); }
 
-  const_iterator end() const { return const_iterator(myUsedSize, *this); }
+  const_iterator end() const noexcept { return const_iterator(myUsedSize, *this); }
 
-  const_iterator cend() const { return const_iterator(myUsedSize, *this); }
+  const_iterator cend() const noexcept { return const_iterator(myUsedSize, *this); }
 
 public: //! @name public methods
   NCollection_DynamicArray(const Standard_Integer theIncrement = 256)
@@ -147,21 +147,21 @@ public: //! @name public methods
   ~NCollection_DynamicArray() { Clear(true); }
 
   //! Total number of items
-  Standard_Integer Length() const { return static_cast<int>(myUsedSize); }
+  Standard_Integer Length() const noexcept { return static_cast<int>(myUsedSize); }
 
   //! Total number of items in the vector
-  Standard_Integer Size() const { return Length(); }
+  Standard_Integer Size() const noexcept { return Length(); }
 
   //! Method for consistency with other collections.
   //! @return Lower bound (inclusive) for iteration.
-  Standard_Integer Lower() const { return 0; }
+  Standard_Integer Lower() const noexcept { return 0; }
 
   //! Method for consistency with other collections.
   //! @return Upper bound (inclusive) for iteration.
-  Standard_Integer Upper() const { return Length() - 1; }
+  Standard_Integer Upper() const noexcept { return Length() - 1; }
 
   //! Empty query
-  Standard_Boolean IsEmpty() const { return myUsedSize == 0; }
+  Standard_Boolean IsEmpty() const noexcept { return myUsedSize == 0; }
 
   //! Assignment to the collection of the same type
   NCollection_DynamicArray& Assign(const NCollection_DynamicArray& theOther,
@@ -262,41 +262,50 @@ public: //! @name public methods
   }
 
   //! Operator() - query the const value
-  const_reference operator()(const Standard_Integer theIndex) const { return Value(theIndex); }
+  const_reference operator()(const Standard_Integer theIndex) const noexcept
+  {
+    return Value(theIndex);
+  }
 
   //! Operator[] - query the const value
-  const_reference operator[](const Standard_Integer theIndex) const { return Value(theIndex); }
+  const_reference operator[](const Standard_Integer theIndex) const noexcept
+  {
+    return Value(theIndex);
+  }
 
   //! Operator[] - query the const value
-  const_reference operator[](const size_t theIndex) const { return at(theIndex); }
+  const_reference operator[](const size_t theIndex) const noexcept { return at(theIndex); }
 
-  const_reference Value(const Standard_Integer theIndex) const
+  const_reference Value(const Standard_Integer theIndex) const noexcept
   {
     return at(static_cast<int>(theIndex));
   }
 
   //! @return first element
-  const_reference First() const { return getArray()[0][0]; }
+  const_reference First() const noexcept { return getArray()[0][0]; }
 
   //! @return first element
-  reference ChangeFirst() { return getArray()[0][0]; }
+  reference ChangeFirst() noexcept { return getArray()[0][0]; }
 
   //! @return last element
-  const_reference Last() const { return at(myUsedSize - 1); }
+  const_reference Last() const noexcept { return at(myUsedSize - 1); }
 
   //! @return last element
-  reference ChangeLast() { return at(myUsedSize - 1); }
+  reference ChangeLast() noexcept { return at(myUsedSize - 1); }
 
   //! Operator() - query the value
-  reference operator()(const Standard_Integer theIndex) { return ChangeValue(theIndex); }
+  reference operator()(const Standard_Integer theIndex) noexcept { return ChangeValue(theIndex); }
 
   //! Operator[] - query the value
-  reference operator[](const Standard_Integer theIndex) { return ChangeValue(theIndex); }
+  reference operator[](const Standard_Integer theIndex) noexcept { return ChangeValue(theIndex); }
 
   //! Operator[] - query the value
-  reference operator[](const size_t theIndex) { return at(theIndex); }
+  reference operator[](const size_t theIndex) noexcept { return at(theIndex); }
 
-  reference ChangeValue(const Standard_Integer theIndex) { return at(static_cast<int>(theIndex)); }
+  reference ChangeValue(const Standard_Integer theIndex) noexcept
+  {
+    return at(static_cast<int>(theIndex));
+  }
 
   //! SetValue () - set or append a value
   reference SetValue(const Standard_Integer theIndex, const TheItemType& theValue)
@@ -363,7 +372,7 @@ public: //! @name public methods
     myUsedSize = 0;
   }
 
-  void SetIncrement(const Standard_Integer theIncrement)
+  void SetIncrement(const Standard_Integer theIncrement) noexcept
   {
     if (myUsedSize != 0)
     {
@@ -376,7 +385,7 @@ public: //! @name public methods
   friend const_iterator;
 
 protected:
-  size_t availableSize() const { return myContainer.Size() * myInternalSize; }
+  size_t availableSize() const noexcept { return myContainer.Size() * myInternalSize; }
 
   TheItemType* expandArray()
   {
@@ -385,12 +394,12 @@ protected:
     return aNewBlock;
   }
 
-  reference at(const size_t theInd)
+  reference at(const size_t theInd) noexcept
   {
     return getArray()[theInd / myInternalSize][theInd % myInternalSize];
   }
 
-  const_reference at(const size_t theInd) const
+  const_reference at(const size_t theInd) const noexcept
   {
     return getArray()[theInd / myInternalSize][theInd % myInternalSize];
   }
@@ -413,7 +422,7 @@ protected:
   }
 
   //! Wrapper to extract array
-  TheItemType** getArray() const { return (TheItemType**)myContainer.GetArray(); }
+  TheItemType** getArray() const noexcept { return (TheItemType**)myContainer.GetArray(); }
 
 protected:
   vector         myContainer;
index b934061b99714a36543878f8c33b924c0afebc30..d9de48c389cd421a4f75beed439b9d6a41d0213f 100644 (file)
@@ -212,11 +212,11 @@ Standard_Boolean NCollection_EBTree<TheObjType, TheBndType>::Remove(const TheObj
                                                                                                    \
     /* Access to the extended tree algorithm */                                                    \
                                                                                                    \
-    const EBTree& ETree() const                                                                    \
+    const EBTree& ETree() const noexcept                                                           \
     {                                                                                              \
       return (const EBTree&)Tree();                                                                \
     }                                                                                              \
-    EBTree& ChangeETree()                                                                          \
+    EBTree& ChangeETree() noexcept                                                                 \
     {                                                                                              \
       return (EBTree&)ChangeTree();                                                                \
     }                                                                                              \
index b326806efd9c1d9ce4fe72f582c00cbf35ee2085..3934616a2ce72a44304f9181d239ada242ed07bb 100644 (file)
@@ -83,26 +83,30 @@ public:
   }
 
   //! Cast handle to contained type
-  T* get() { return ((Ptr*)opencascade::handle<Standard_Transient>::get())->myPtr; }
+  T* get() noexcept { return ((Ptr*)opencascade::handle<Standard_Transient>::get())->myPtr; }
 
   //! Cast handle to contained type
-  const T* get() const { return ((Ptr*)opencascade::handle<Standard_Transient>::get())->myPtr; }
+  const T* get() const noexcept
+  {
+    return ((Ptr*)opencascade::handle<Standard_Transient>::get())->myPtr;
+  }
 
   //! Cast handle to contained type
-  T* operator->() { return get(); }
+  T* operator->() noexcept { return get(); }
 
   //! Cast handle to contained type
-  const T* operator->() const { return get(); }
+  const T* operator->() const noexcept { return get(); }
 
   //! Cast handle to contained type
-  T& operator*() { return *get(); }
+  T& operator*() noexcept { return *get(); }
 
   //! Cast handle to contained type
-  const T& operator*() const { return *get(); }
+  const T& operator*() const noexcept { return *get(); }
 
   //! Downcast arbitrary Handle to the argument type if contained
   //! object is Handle for this type; returns null otherwise
-  static NCollection_Handle<T> DownCast(const opencascade::handle<Standard_Transient>& theOther)
+  static NCollection_Handle<T> DownCast(
+    const opencascade::handle<Standard_Transient>& theOther) noexcept
   {
     return NCollection_Handle<T>(dynamic_cast<Ptr*>(theOther.get()), 0);
   }
index 9b426a7ca91d32ea98640e1aff7736ef0822fc88..e74c5f651623d7529c265977d8b72f4f26a999ce 100644 (file)
@@ -105,13 +105,14 @@ private:
     }
 
     //! Key1
-    TheKeyType& Key1() { return myKey1; }
+    TheKeyType& Key1() noexcept { return myKey1; }
 
     //! Index
-    Standard_Integer& Index() { return myIndex; }
+    Standard_Integer& Index() noexcept { return myIndex; }
 
     //! Static deleter to be passed to BaseList
-    static void delNode(NCollection_ListNode* theNode, Handle(NCollection_BaseAllocator)& theAl)
+    static void delNode(NCollection_ListNode*              theNode,
+                        Handle(NCollection_BaseAllocator)& theAl) noexcept
     {
       ((IndexedDataMapNode*)theNode)->~IndexedDataMapNode();
       theAl->Free(theNode);
@@ -142,10 +143,13 @@ public:
     }
 
     //! Query if the end of collection is reached by iterator
-    Standard_Boolean More(void) const { return (myMap != NULL) && (myIndex <= myMap->Extent()); }
+    Standard_Boolean More(void) const noexcept
+    {
+      return (myMap != NULL) && (myIndex <= myMap->Extent());
+    }
 
     //! Make a step along the collection
-    void Next(void) { ++myIndex; }
+    void Next(void) noexcept { ++myIndex; }
 
     //! Value access
     const TheItemType& Value(void) const
@@ -169,7 +173,7 @@ public:
     }
 
     //! Performs comparison of two iterators.
-    Standard_Boolean IsEqual(const Iterator& theOther) const
+    Standard_Boolean IsEqual(const Iterator& theOther) const noexcept
     {
       return myMap == theOther.myMap && myIndex == theOther.myIndex;
     }
@@ -187,16 +191,16 @@ public:
     const_iterator;
 
   //! Returns an iterator pointing to the first element in the map.
-  iterator begin() const { return Iterator(*this); }
+  iterator begin() const noexcept { return Iterator(*this); }
 
   //! Returns an iterator referring to the past-the-end element in the map.
-  iterator end() const { return Iterator(); }
+  iterator end() const noexcept { return Iterator(); }
 
   //! Returns a const iterator pointing to the first element in the map.
-  const_iterator cbegin() const { return Iterator(*this); }
+  const_iterator cbegin() const noexcept { return Iterator(*this); }
 
   //! Returns a const iterator referring to the past-the-end element in the map.
-  const_iterator cend() const { return Iterator(); }
+  const_iterator cend() const noexcept { return Iterator(); }
 
 public:
   // ---------- PUBLIC METHODS ------------
@@ -229,7 +233,7 @@ public:
 
   //! Exchange the content of two maps without re-allocations.
   //! Notice that allocators will be swapped as well!
-  void Exchange(NCollection_IndexedDataMap& theOther) { this->exchangeMapsData(theOther); }
+  void Exchange(NCollection_IndexedDataMap& theOther) noexcept { this->exchangeMapsData(theOther); }
 
   //! Assignment.
   //! This method does not change the internal allocator.
@@ -653,7 +657,7 @@ public:
   virtual ~NCollection_IndexedDataMap(void) { Clear(true); }
 
   //! Size
-  Standard_Integer Size(void) const { return Extent(); }
+  Standard_Integer Size(void) const noexcept { return Extent(); }
 
 protected:
   //! Lookup for particular key in map.
index 85561d10ad9bbfb9d939e1ae71264f0135ba2135..eedb7d07e3c45c46bb46ffb07c09ca5d00a66605 100644 (file)
@@ -35,21 +35,21 @@ public:
   using reference         = typename std::conditional<IsConstant, const ItemType&, ItemType&>::type;
 
   //! Default constructor
-  NCollection_IndexedIterator()
+  NCollection_IndexedIterator() noexcept
       : myIndex(0),
         myIndexedMap(nullptr)
   {
   }
 
   //! Constructor from NCollection_Indexed*Map
-  NCollection_IndexedIterator(const BaseIndexedMap& theMap)
+  NCollection_IndexedIterator(const BaseIndexedMap& theMap) noexcept
       : myIndex(0),
         myIndexedMap((&const_cast<BaseIndexedMap&>(theMap)))
   {
   }
 
   //! Constructor from NCollection_Indexed*Map
-  NCollection_IndexedIterator(const size_t theIndex, const BaseIndexedMap& theMap)
+  NCollection_IndexedIterator(const size_t theIndex, const BaseIndexedMap& theMap) noexcept
       : myIndex(theIndex),
         myIndexedMap(&const_cast<BaseIndexedMap&>(theMap))
   {
@@ -57,7 +57,7 @@ public:
 
   //! Cast from non-const variant to const one
   NCollection_IndexedIterator(
-    const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, false>& theOther)
+    const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, false>& theOther) noexcept
       : myIndex(theOther.myIndex),
         myIndexedMap(theOther.myIndexedMap)
   {
@@ -65,7 +65,7 @@ public:
 
   //! Assignment of non-const iterator to const one
   NCollection_IndexedIterator& operator=(
-    const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, false>& theOther)
+    const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, false>& theOther) noexcept
   {
     myIndex      = theOther.myIndex;
     myIndexedMap = theOther.myIndexedMap;
@@ -90,7 +90,7 @@ protected: //! @name methods related to forward STL iterator
 
 public: //! @name methods related to forward STL iterator
   //! Test for equality
-  bool operator==(const NCollection_IndexedIterator& theOther) const
+  bool operator==(const NCollection_IndexedIterator& theOther) const noexcept
   {
     return myIndexedMap == theOther.myIndexedMap && myIndex == theOther.myIndex;
   }
@@ -98,7 +98,7 @@ public: //! @name methods related to forward STL iterator
   template <bool theOtherIsConstant>
   bool operator==(
     const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, theOtherIsConstant>&
-      theOther) const
+      theOther) const noexcept
   {
     return myIndexedMap == theOther.myIndexedMap && myIndex == theOther.myIndex;
   }
@@ -106,13 +106,13 @@ public: //! @name methods related to forward STL iterator
   template <bool theOtherIsConstant>
   bool operator!=(
     const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, theOtherIsConstant>&
-      theOther) const
+      theOther) const noexcept
   {
     return myIndexedMap != theOther.myIndexedMap || myIndex != theOther.myIndex;
   }
 
   //! Test for inequality
-  bool operator!=(const NCollection_IndexedIterator& theOther) const
+  bool operator!=(const NCollection_IndexedIterator& theOther) const noexcept
   {
     return !(*this == theOther);
   }
@@ -130,14 +130,14 @@ public: //! @name methods related to forward STL iterator
   }
 
   //! Prefix increment
-  NCollection_IndexedIterator& operator++()
+  NCollection_IndexedIterator& operator++() noexcept
   {
     myIndex++;
     return *this;
   }
 
   //! Postfix increment
-  NCollection_IndexedIterator operator++(int)
+  NCollection_IndexedIterator operator++(int) noexcept
   {
     const NCollection_IndexedIterator theOld(*this);
     ++(*this);
@@ -146,7 +146,7 @@ public: //! @name methods related to forward STL iterator
 
 public: //! @name methods related to bidirectional STL iterator
   //! Prefix decrement
-  NCollection_IndexedIterator& operator--()
+  NCollection_IndexedIterator& operator--() noexcept
   {
     Standard_STATIC_ASSERT(
       (opencascade::std::is_same<std::bidirectional_iterator_tag, Category>::value
@@ -156,7 +156,7 @@ public: //! @name methods related to bidirectional STL iterator
   }
 
   //! Postfix decrement
-  NCollection_IndexedIterator operator--(int)
+  NCollection_IndexedIterator operator--(int) noexcept
   {
     NCollection_IndexedIterator theOld(*this);
     --(*this);
@@ -166,7 +166,7 @@ public: //! @name methods related to bidirectional STL iterator
 public: //! @name methods related to random access STL iterator
   //! Move forward
   NCollection_IndexedIterator& operator+=(
-    typename NCollection_IndexedIterator::difference_type theOffset)
+    typename NCollection_IndexedIterator::difference_type theOffset) noexcept
   {
     Standard_STATIC_ASSERT(
       (opencascade::std::is_same<std::random_access_iterator_tag, Category>::value));
@@ -176,7 +176,7 @@ public: //! @name methods related to random access STL iterator
 
   //! Addition
   NCollection_IndexedIterator operator+(
-    typename NCollection_IndexedIterator::difference_type theOffset) const
+    typename NCollection_IndexedIterator::difference_type theOffset) const noexcept
   {
     NCollection_IndexedIterator aTemp(*this);
     return aTemp += theOffset;
@@ -184,14 +184,14 @@ public: //! @name methods related to random access STL iterator
 
   //! Move backward
   NCollection_IndexedIterator& operator-=(
-    typename NCollection_IndexedIterator::difference_type theOffset)
+    typename NCollection_IndexedIterator::difference_type theOffset) noexcept
   {
     return *this += -theOffset;
   }
 
   //! Decrease
   NCollection_IndexedIterator operator-(
-    typename NCollection_IndexedIterator::difference_type theOffset) const
+    typename NCollection_IndexedIterator::difference_type theOffset) const noexcept
   {
     NCollection_IndexedIterator aTemp(*this);
     return aTemp += -theOffset;
@@ -199,7 +199,7 @@ public: //! @name methods related to random access STL iterator
 
   //! Difference
   typename NCollection_IndexedIterator::difference_type operator-(
-    const NCollection_IndexedIterator& theOther) const
+    const NCollection_IndexedIterator& theOther) const noexcept
   {
     Standard_STATIC_ASSERT(
       (opencascade::std::is_same<std::random_access_iterator_tag, Category>::value));
@@ -214,19 +214,28 @@ public: //! @name methods related to random access STL iterator
   }
 
   //! Comparison
-  bool operator<(const NCollection_IndexedIterator& theOther) const
+  bool operator<(const NCollection_IndexedIterator& theOther) const noexcept
   {
     return (*this - theOther) < 0;
   }
 
   //! Comparison
-  bool operator>(const NCollection_IndexedIterator& theOther) const { return theOther < *this; }
+  bool operator>(const NCollection_IndexedIterator& theOther) const noexcept
+  {
+    return theOther < *this;
+  }
 
   //! Comparison
-  bool operator<=(const NCollection_IndexedIterator& theOther) const { return !(theOther < *this); }
+  bool operator<=(const NCollection_IndexedIterator& theOther) const noexcept
+  {
+    return !(theOther < *this);
+  }
 
   //! Comparison
-  bool operator>=(const NCollection_IndexedIterator& theOther) const { return !(*this < theOther); }
+  bool operator>=(const NCollection_IndexedIterator& theOther) const noexcept
+  {
+    return !(*this < theOther);
+  }
 
   friend class NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, !IsConstant>;
 
index cd2fb190faa5e58ea9447bd2b09f24fb39190609..a26186e6c1f01641c9283452d8de6e36e8aa1677 100644 (file)
@@ -67,13 +67,14 @@ protected:
     }
 
     //! Key1
-    TheKeyType& Key1() { return this->ChangeValue(); }
+    TheKeyType& Key1() noexcept { return this->ChangeValue(); }
 
     //! Index
-    Standard_Integer& Index() { return myIndex; }
+    Standard_Integer& Index() noexcept { return myIndex; }
 
     //! Static deleter to be passed to BaseList
-    static void delNode(NCollection_ListNode* theNode, Handle(NCollection_BaseAllocator)& theAl)
+    static void delNode(NCollection_ListNode*              theNode,
+                        Handle(NCollection_BaseAllocator)& theAl) noexcept
     {
       ((IndexedMapNode*)theNode)->~IndexedMapNode();
       theAl->Free(theNode);
@@ -103,10 +104,13 @@ public:
     }
 
     //! Query if the end of collection is reached by iterator
-    Standard_Boolean More(void) const { return (myMap != NULL) && (myIndex <= myMap->Extent()); }
+    Standard_Boolean More(void) const noexcept
+    {
+      return (myMap != NULL) && (myIndex <= myMap->Extent());
+    }
 
     //! Make a step along the collection
-    void Next(void) { myIndex++; }
+    void Next(void) noexcept { myIndex++; }
 
     //! Value access
     const TheKeyType& Value(void) const
@@ -116,7 +120,7 @@ public:
     }
 
     //! Performs comparison of two iterators.
-    Standard_Boolean IsEqual(const Iterator& theOther) const
+    Standard_Boolean IsEqual(const Iterator& theOther) const noexcept
     {
       return myMap == theOther.myMap && myIndex == theOther.myIndex;
     }
@@ -131,10 +135,10 @@ public:
     const_iterator;
 
   //! Returns a const iterator pointing to the first element in the map.
-  const_iterator cbegin() const { return Iterator(*this); }
+  const_iterator cbegin() const noexcept { return Iterator(*this); }
 
   //! Returns a const iterator referring to the past-the-end element in the map.
-  const_iterator cend() const { return Iterator(); }
+  const_iterator cend() const noexcept { return Iterator(); }
 
 public:
   // ---------- PUBLIC METHODS ------------
@@ -167,7 +171,7 @@ public:
 
   //! Exchange the content of two maps without re-allocations.
   //! Notice that allocators will be swapped as well!
-  void Exchange(NCollection_IndexedMap& theOther) { this->exchangeMapsData(theOther); }
+  void Exchange(NCollection_IndexedMap& theOther) noexcept { this->exchangeMapsData(theOther); }
 
   //! Assign.
   //! This method does not change the internal allocator.
@@ -448,7 +452,7 @@ public:
   virtual ~NCollection_IndexedMap(void) { Clear(true); }
 
   //! Size
-  Standard_Integer Size(void) const { return Extent(); }
+  Standard_Integer Size(void) const noexcept { return Extent(); }
 
 protected:
   //! Lookup for particular key in map.
index 55369b57d6147f33edd29e4177526e0b75224bad..810f6b150f10fd569446bc767d17432c4adcb395 100644 (file)
@@ -57,7 +57,7 @@ public:
   {
   }
 
-  ~NCollection_Iterator() {}
+  ~NCollection_Iterator() noexcept {}
 
   void Init(Container& theList)
   {
@@ -67,37 +67,37 @@ public:
 
   void Init(const Container& theList) { Init(const_cast<Container&>(theList)); }
 
-  virtual bool More() const { return myCur != myLast; }
+  virtual bool More() const noexcept { return myCur != myLast; }
 
   void Initialize(Container& theList) { Init(theList); }
 
   void Initialize(const Container& theList) { Init(theList); }
 
-  const typename Container::iterator& ValueIter() const { return myCur; }
+  const typename Container::iterator& ValueIter() const noexcept { return myCur; }
 
-  typename Container::iterator& ChangeValueIter() { return myCur; }
+  typename Container::iterator& ChangeValueIter() noexcept { return myCur; }
 
-  const typename Container::iterator& EndIter() const { return myLast; }
+  const typename Container::iterator& EndIter() const noexcept { return myLast; }
 
-  typename Container::iterator& ChangeEndIter() { return myLast; }
+  typename Container::iterator& ChangeEndIter() noexcept { return myLast; }
 
-  virtual void Next() { ++(myCur); }
+  virtual void Next() noexcept { ++(myCur); }
 
   const typename Container::const_reference Value() const { return *myCur; }
 
   const typename Container::reference ChangeValue() { return *myCur; }
 
-  bool operator==(const NCollection_Iterator& theOther)
+  bool operator==(const NCollection_Iterator& theOther) noexcept
   {
     return myLast == theOther.myLast && myCur == theOther.myCur;
   }
 
-  bool operator!=(const NCollection_Iterator& theOther)
+  bool operator!=(const NCollection_Iterator& theOther) noexcept
   {
     return myLast != theOther.myLast || myCur != theOther.myCur;
   }
 
-  NCollection_Iterator& operator=(const NCollection_Iterator& theOther)
+  NCollection_Iterator& operator=(const NCollection_Iterator& theOther) noexcept
   {
     if (this != &theOther)
     {
@@ -107,7 +107,7 @@ public:
     return *this;
   }
 
-  NCollection_Iterator& operator=(NCollection_Iterator&& theOther)
+  NCollection_Iterator& operator=(NCollection_Iterator&& theOther) noexcept
   {
     if (this != &theOther)
     {
index da854fb2c6c9e51c7b5db33c722b624ff72af52e..3ee27ba5a84687c192f791a50a6e8a7fe6942070 100644 (file)
@@ -45,16 +45,16 @@ public:
     const_iterator;
 
   //! Returns an iterator pointing to the first element in the list.
-  iterator begin() const { return Iterator(*this); }
+  iterator begin() const noexcept { return Iterator(*this); }
 
   //! Returns an iterator referring to the past-the-end element in the list.
-  iterator end() const { return Iterator(); }
+  iterator end() const noexcept { return Iterator(); }
 
   //! Returns a const iterator pointing to the first element in the list.
-  const_iterator cbegin() const { return Iterator(*this); }
+  const_iterator cbegin() const noexcept { return Iterator(*this); }
 
   //! Returns a const iterator referring to the past-the-end element in the list.
-  const_iterator cend() const { return Iterator(); }
+  const_iterator cend() const noexcept { return Iterator(); }
 
 public:
   // ---------- PUBLIC METHODS ------------
@@ -86,7 +86,7 @@ public:
   }
 
   //! Size - Number of items
-  Standard_Integer Size(void) const { return Extent(); }
+  Standard_Integer Size(void) const noexcept { return Extent(); }
 
   //! Replace this list by the items of another list (theOther parameter).
   //! This method does not change the internal allocator.
index b1d7c28f488c191f2485bedbeb6020aecfb5012c..ea258b89c5a015b01c67446a3fd315625dc02188 100644 (file)
@@ -30,23 +30,23 @@ public:
   DEFINE_NCOLLECTION_ALLOC
 public:
   //! The only constructor
-  NCollection_ListNode(NCollection_ListNode* theNext)
+  NCollection_ListNode(NCollection_ListNode* theNext) noexcept
       : myNext(theNext)
   {
   }
 
   //! Next pointer access
-  NCollection_ListNode*& Next(void) { return myNext; }
+  NCollection_ListNode*& Next(void) noexcept { return myNext; }
 
   //! Next pointer const access
-  NCollection_ListNode* Next(void) const { return myNext; }
+  NCollection_ListNode* Next(void) const noexcept { return myNext; }
 
 private:
   //! operator= - forbidden
-  NCollection_ListNode& operator=(const NCollection_ListNode&);
+  NCollection_ListNode& operator=(const NCollection_ListNode&) = delete;
 
   //! copy constructor - forbidden
-  NCollection_ListNode(const NCollection_ListNode&);
+  NCollection_ListNode(const NCollection_ListNode&) = delete;
 
 private:
   NCollection_ListNode* myNext; //!< Pointer to the next node
index 90a612b9882b7b7a62a0208a823dff127464c05e..07890f8f2497fc073cbfd3a50ef82db4f39b8c26 100644 (file)
@@ -30,7 +30,7 @@ public:
     Allocate(theSize);
   }
 
-  NCollection_LocalArray()
+  NCollection_LocalArray() noexcept
       : myPtr(myBuffer),
         mySize(0)
   {
@@ -49,9 +49,9 @@ public:
     mySize = theSize;
   }
 
-  size_t Size() const { return mySize; }
+  size_t Size() const noexcept { return mySize; }
 
-  operator theItem*() const { return myPtr; }
+  operator theItem*() const noexcept { return myPtr; }
 
 private:
   NCollection_LocalArray(const NCollection_LocalArray&);
index 89dcb80a18d1124eafdc5513fa5162c4f1ceb15f..0d042d47eff636b5addf02a83a0224e2133f138e 100644 (file)
@@ -79,7 +79,7 @@ public:
     }
 
     //! Key
-    const TheKeyType& Key(void) { return this->Value(); }
+    const TheKeyType& Key(void) noexcept { return this->Value(); }
   };
 
 public:
@@ -100,10 +100,10 @@ public:
     }
 
     //! Query if the end of collection is reached by iterator
-    Standard_Boolean More(void) const { return PMore(); }
+    Standard_Boolean More(void) const noexcept { return PMore(); }
 
     //! Make a step along the collection
-    void Next(void) { PNext(); }
+    void Next(void) noexcept { PNext(); }
 
     //! Value inquiry
     const TheKeyType& Value(void) const
@@ -125,10 +125,10 @@ public:
     const_iterator;
 
   //! Returns a const iterator pointing to the first element in the map.
-  const_iterator cbegin() const { return Iterator(*this); }
+  const_iterator cbegin() const noexcept { return Iterator(*this); }
 
   //! Returns a const iterator referring to the past-the-end element in the map.
-  const_iterator cend() const { return Iterator(); }
+  const_iterator cend() const noexcept { return Iterator(); }
 
 public:
   // ---------- PUBLIC METHODS ------------
@@ -166,7 +166,7 @@ public:
 
   //! Exchange the content of two maps without re-allocations.
   //! Notice that allocators will be swapped as well!
-  void Exchange(NCollection_Map& theOther) { this->exchangeMapsData(theOther); }
+  void Exchange(NCollection_Map& theOther) noexcept { this->exchangeMapsData(theOther); }
 
   //! Assign.
   //! This method does not change the internal allocator.
@@ -355,7 +355,7 @@ public:
   virtual ~NCollection_Map(void) { Clear(true); }
 
   //! Size
-  Standard_Integer Size(void) const { return Extent(); }
+  Standard_Integer Size(void) const noexcept { return Extent(); }
 
 public:
   //! Checks if two maps contain exactly the same keys.
index 55a0e8ecde855183d6683f707366a6b4d12ac937..f9335342a47216a0769bbcf11e3409c1a1543f01 100644 (file)
@@ -24,10 +24,10 @@ class NCollection_Mat3
 {
 public:
   //! Return identity matrix.
-  static NCollection_Mat3 Identity() { return NCollection_Mat3(); }
+  static constexpr NCollection_Mat3 Identity() { return NCollection_Mat3(); }
 
   //! Return zero matrix.
-  static NCollection_Mat3 Zero()
+  static constexpr NCollection_Mat3 Zero()
   {
     NCollection_Mat3 aMat;
     aMat.InitZero();
@@ -36,7 +36,7 @@ public:
 
 public:
   //! Empty constructor for identity matrix.
-  NCollection_Mat3() { InitIdentity(); }
+  constexpr NCollection_Mat3() { InitIdentity(); }
 
   //! Conversion constructor (explicitly converts some 3x3 matrix with other element type
   //! to a new 3x3 matrix with the element type Element_t,
@@ -44,7 +44,7 @@ public:
   //! @tparam OtherElement_t the element type of the other 3x3 matrix theOtherVec3
   //! @param theOtherMat3 the 3x3 matrix that needs to be converted
   template <typename OtherElement_t>
-  explicit NCollection_Mat3(const NCollection_Mat3<OtherElement_t>& theOtherMat3)
+  explicit constexpr NCollection_Mat3(const NCollection_Mat3<OtherElement_t>& theOtherMat3) noexcept
   {
     ConvertFrom(theOtherMat3);
   }
@@ -53,7 +53,7 @@ public:
   //! @param[in] theRow  the row.to address.
   //! @param[in] theCol  the column to address.
   //! @return the value of the addressed element.
-  Element_t GetValue(const size_t theRow, const size_t theCol) const
+  constexpr Element_t GetValue(const size_t theRow, const size_t theCol) const noexcept
   {
     return myMat[theCol * 3 + theRow];
   }
@@ -62,7 +62,7 @@ public:
   //! @param[in] theRow  the row.to access.
   //! @param[in] theCol  the column to access.
   //! @return reference on the matrix element.
-  Element_t& ChangeValue(const size_t theRow, const size_t theCol)
+  constexpr Element_t& ChangeValue(const size_t theRow, const size_t theCol) noexcept
   {
     return myMat[theCol * 3 + theRow];
   }
@@ -71,25 +71,27 @@ public:
   //! @param[in] theRow    the row to change.
   //! @param[in] theCol    the column to change.
   //! @param[in] theValue  the value to set.s
-  void SetValue(const size_t theRow, const size_t theCol, const Element_t theValue)
+  constexpr void SetValue(const size_t    theRow,
+                          const size_t    theCol,
+                          const Element_t theValue) noexcept
   {
     myMat[theCol * 3 + theRow] = theValue;
   }
 
   //! Return value.
-  Element_t& operator()(const size_t theRow, const size_t theCol)
+  constexpr Element_t& operator()(const size_t theRow, const size_t theCol) noexcept
   {
     return ChangeValue(theRow, theCol);
   }
 
   //! Return value.
-  Element_t operator()(const size_t theRow, const size_t theCol) const
+  constexpr Element_t operator()(const size_t theRow, const size_t theCol) const noexcept
   {
     return GetValue(theRow, theCol);
   }
 
   //! Return the row.
-  NCollection_Vec3<Element_t> GetRow(const size_t theRow) const
+  constexpr NCollection_Vec3<Element_t> GetRow(const size_t theRow) const noexcept
   {
     return NCollection_Vec3<Element_t>(GetValue(theRow, 0),
                                        GetValue(theRow, 1),
@@ -99,7 +101,7 @@ public:
   //! Change first 3 row values by the passed vector.
   //! @param[in] theRow  the row to change.
   //! @param[in] theVec  the vector of values.
-  void SetRow(const size_t theRow, const NCollection_Vec3<Element_t>& theVec)
+  constexpr void SetRow(const size_t theRow, const NCollection_Vec3<Element_t>& theVec) noexcept
   {
     SetValue(theRow, 0, theVec.x());
     SetValue(theRow, 1, theVec.y());
@@ -107,7 +109,7 @@ public:
   }
 
   //! Return the column.
-  NCollection_Vec3<Element_t> GetColumn(const size_t theCol) const
+  constexpr NCollection_Vec3<Element_t> GetColumn(const size_t theCol) const noexcept
   {
     return NCollection_Vec3<Element_t>(GetValue(0, theCol),
                                        GetValue(1, theCol),
@@ -117,7 +119,7 @@ public:
   //! Change first 3 column values by the passed vector.
   //! @param[in] theCol  the column to change.
   //! @param[in] theVec  the vector of values.
-  void SetColumn(const size_t theCol, const NCollection_Vec3<Element_t>& theVec)
+  constexpr void SetColumn(const size_t theCol, const NCollection_Vec3<Element_t>& theVec) noexcept
   {
     SetValue(0, theCol, theVec.x());
     SetValue(1, theCol, theVec.y());
@@ -126,14 +128,14 @@ public:
 
   //! Get vector of diagonal elements.
   //! @return vector of diagonal elements.
-  NCollection_Vec3<Element_t> GetDiagonal() const
+  constexpr NCollection_Vec3<Element_t> GetDiagonal() const noexcept
   {
     return NCollection_Vec3<Element_t>(GetValue(0, 0), GetValue(1, 1), GetValue(2, 2));
   }
 
   //! Change first 3 elements of the diagonal matrix.
   //! @param theVec the vector of values.
-  void SetDiagonal(const NCollection_Vec3<Element_t>& theVec)
+  constexpr void SetDiagonal(const NCollection_Vec3<Element_t>& theVec) noexcept
   {
     SetValue(0, 0, theVec.x());
     SetValue(1, 1, theVec.y());
@@ -141,41 +143,84 @@ public:
   }
 
   //! Initialize the zero matrix.
-  void InitZero() { std::memcpy(this, MyZeroArray, sizeof(NCollection_Mat3)); }
+  constexpr void InitZero() noexcept
+  {
+    for (int i = 0; i < 9; ++i)
+    {
+      myMat[i] = MyZeroArray[i];
+    }
+  }
 
   //! Checks the matrix for zero (without tolerance).
-  bool IsZero() const { return std::memcmp(this, MyZeroArray, sizeof(NCollection_Mat3)) == 0; }
+  constexpr bool IsZero() const noexcept
+  {
+    for (int i = 0; i < 9; ++i)
+    {
+      if (myMat[i] != MyZeroArray[i])
+      {
+        return false;
+      }
+    }
+    return true;
+  }
 
   //! Initialize the identity matrix.
-  void InitIdentity() { std::memcpy(this, MyIdentityArray, sizeof(NCollection_Mat3)); }
+  constexpr void InitIdentity() noexcept
+  {
+    for (int i = 0; i < 9; ++i)
+    {
+      myMat[i] = MyIdentityArray[i];
+    }
+  }
 
   //! Checks the matrix for identity (without tolerance).
-  bool IsIdentity() const
+  constexpr bool IsIdentity() const noexcept
   {
-    return std::memcmp(this, MyIdentityArray, sizeof(NCollection_Mat3)) == 0;
+    for (int i = 0; i < 9; ++i)
+    {
+      if (myMat[i] != MyIdentityArray[i])
+      {
+        return false;
+      }
+    }
+    return true;
   }
 
   //! Check this matrix for equality with another matrix (without tolerance!).
-  bool IsEqual(const NCollection_Mat3& theOther) const
+  constexpr bool IsEqual(const NCollection_Mat3& theOther) const noexcept
   {
-    return std::memcmp(this, &theOther, sizeof(NCollection_Mat3)) == 0;
+    for (int i = 0; i < 9; ++i)
+    {
+      if (myMat[i] != theOther.myMat[i])
+      {
+        return false;
+      }
+    }
+    return true;
   }
 
   //! Comparison operator.
-  bool operator==(const NCollection_Mat3& theMat) const { return IsEqual(theMat); }
+  constexpr bool operator==(const NCollection_Mat3& theMat) const noexcept
+  {
+    return IsEqual(theMat);
+  }
 
   //! Check this vector with another vector for non-equality (without tolerance!).
-  bool operator!=(const NCollection_Mat3& theOther) const { return !IsEqual(theOther); }
+  constexpr bool operator!=(const NCollection_Mat3& theOther) const noexcept
+  {
+    return !IsEqual(theOther);
+  }
 
   //! Raw access to the data (for OpenGL exchange).
   //! the data is returned in column-major order.
-  const Element_t* GetData() const { return myMat; }
+  constexpr const Element_t* GetData() const noexcept { return myMat; }
 
-  Element_t* ChangeData() { return myMat; }
+  constexpr Element_t* ChangeData() noexcept { return myMat; }
 
   //! Multiply by the vector (M * V).
   //! @param[in] theVec  the vector to multiply.
-  NCollection_Vec3<Element_t> operator*(const NCollection_Vec3<Element_t>& theVec) const
+  constexpr NCollection_Vec3<Element_t> operator*(
+    const NCollection_Vec3<Element_t>& theVec) const noexcept
   {
     return NCollection_Vec3<Element_t>(
       GetValue(0, 0) * theVec.x() + GetValue(0, 1) * theVec.y() + GetValue(0, 2) * theVec.z(),
@@ -186,15 +231,15 @@ public:
   //! Compute matrix multiplication product: A * B.
   //! @param[in] theMatA  the matrix "A".
   //! @param[in] theMatB  the matrix "B".
-  static NCollection_Mat3 Multiply(const NCollection_Mat3& theMatA, const NCollection_Mat3& theMatB)
+  static constexpr NCollection_Mat3 Multiply(const NCollection_Mat3& theMatA,
+                                             const NCollection_Mat3& theMatB) noexcept
   {
     NCollection_Mat3 aMatRes;
 
-    size_t aInputElem;
     for (size_t aResElem = 0; aResElem < 9; ++aResElem)
     {
       aMatRes.myMat[aResElem] = (Element_t)0;
-      for (aInputElem = 0; aInputElem < 3; ++aInputElem)
+      for (size_t aInputElem = 0; aInputElem < 3; ++aInputElem)
       {
         aMatRes.myMat[aResElem] +=
           theMatA.GetValue(aResElem % 3, aInputElem) * theMatB.GetValue(aInputElem, aResElem / 3);
@@ -206,11 +251,14 @@ public:
 
   //! Compute matrix multiplication.
   //! @param[in] theMat  the matrix to multiply.
-  void Multiply(const NCollection_Mat3& theMat) { *this = Multiply(*this, theMat); }
+  constexpr void Multiply(const NCollection_Mat3& theMat) noexcept
+  {
+    *this = Multiply(*this, theMat);
+  }
 
   //! Multiply by the another matrix.
   //! @param[in] theMat  the other matrix.
-  NCollection_Mat3& operator*=(const NCollection_Mat3& theMat)
+  constexpr NCollection_Mat3& operator*=(const NCollection_Mat3& theMat) noexcept
   {
     Multiply(theMat);
     return *this;
@@ -219,7 +267,8 @@ public:
   //! Compute matrix multiplication product.
   //! @param[in] theMat  the other matrix.
   //! @return result of multiplication.
-  Standard_NODISCARD NCollection_Mat3 operator*(const NCollection_Mat3& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat3 operator*(
+    const NCollection_Mat3& theMat) const noexcept
   {
     return Multiplied(theMat);
   }
@@ -227,7 +276,8 @@ public:
   //! Compute matrix multiplication product.
   //! @param[in] theMat  the other matrix.
   //! @return result of multiplication.
-  Standard_NODISCARD NCollection_Mat3 Multiplied(const NCollection_Mat3& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat3 Multiplied(
+    const NCollection_Mat3& theMat) const noexcept
   {
     NCollection_Mat3 aTempMat(*this);
     aTempMat *= theMat;
@@ -236,7 +286,7 @@ public:
 
   //! Compute per-component multiplication.
   //! @param[in] theFactor  the scale factor.
-  void Multiply(const Element_t theFactor)
+  constexpr void Multiply(const Element_t theFactor) noexcept
   {
     for (size_t i = 0; i < 9; ++i)
     {
@@ -246,7 +296,7 @@ public:
 
   //! Compute per-element multiplication.
   //! @param[in] theFactor  the scale factor.
-  NCollection_Mat3& operator*=(const Element_t theFactor)
+  constexpr NCollection_Mat3& operator*=(const Element_t theFactor) noexcept
   {
     Multiply(theFactor);
     return *this;
@@ -255,7 +305,7 @@ public:
   //! Compute per-element multiplication.
   //! @param[in] theFactor  the scale factor.
   //! @return the result of multiplication.
-  Standard_NODISCARD NCollection_Mat3 operator*(const Element_t theFactor) const
+  Standard_NODISCARD constexpr NCollection_Mat3 operator*(const Element_t theFactor) const noexcept
   {
     return Multiplied(theFactor);
   }
@@ -263,7 +313,7 @@ public:
   //! Compute per-element multiplication.
   //! @param[in] theFactor  the scale factor.
   //! @return the result of multiplication.
-  Standard_NODISCARD NCollection_Mat3 Multiplied(const Element_t theFactor) const
+  Standard_NODISCARD constexpr NCollection_Mat3 Multiplied(const Element_t theFactor) const noexcept
   {
     NCollection_Mat3 aTempMat(*this);
     aTempMat *= theFactor;
@@ -272,7 +322,7 @@ public:
 
   //! Compute per-component division.
   //! @param[in] theFactor  the scale factor.
-  void Divide(const Element_t theFactor)
+  constexpr void Divide(const Element_t theFactor)
   {
     for (size_t i = 0; i < 9; ++i)
     {
@@ -282,14 +332,14 @@ public:
 
   //! Per-component division.
   //! @param[in] theScalar  the scale factor.
-  NCollection_Mat3& operator/=(const Element_t theScalar)
+  constexpr NCollection_Mat3& operator/=(const Element_t theScalar)
   {
     Divide(theScalar);
     return *this;
   }
 
   //! Divides all the coefficients of the matrix by scalar.
-  Standard_NODISCARD NCollection_Mat3 Divided(const Element_t theScalar) const
+  Standard_NODISCARD constexpr NCollection_Mat3 Divided(const Element_t theScalar) const
   {
     NCollection_Mat3 aTempMat(*this);
     aTempMat /= theScalar;
@@ -297,13 +347,13 @@ public:
   }
 
   //! Divides all the coefficients of the matrix by scalar.
-  Standard_NODISCARD NCollection_Mat3 operator/(const Element_t theScalar) const
+  Standard_NODISCARD constexpr NCollection_Mat3 operator/(const Element_t theScalar) const
   {
     return Divided(theScalar);
   }
 
   //! Per-component addition of another matrix.
-  void Add(const NCollection_Mat3& theMat)
+  constexpr void Add(const NCollection_Mat3& theMat) noexcept
   {
     for (size_t i = 0; i < 9; ++i)
     {
@@ -312,14 +362,14 @@ public:
   }
 
   //! Per-component addition of another matrix.
-  NCollection_Mat3& operator+=(const NCollection_Mat3& theMat)
+  constexpr NCollection_Mat3& operator+=(const NCollection_Mat3& theMat) noexcept
   {
     Add(theMat);
     return *this;
   }
 
   //! Per-component subtraction of another matrix.
-  void Subtract(const NCollection_Mat3& theMat)
+  constexpr void Subtract(const NCollection_Mat3& theMat) noexcept
   {
     for (size_t i = 0; i < 9; ++i)
     {
@@ -328,14 +378,14 @@ public:
   }
 
   //! Per-component subtraction of another matrix.
-  NCollection_Mat3& operator-=(const NCollection_Mat3& theMat)
+  constexpr NCollection_Mat3& operator-=(const NCollection_Mat3& theMat) noexcept
   {
     Subtract(theMat);
     return *this;
   }
 
   //! Per-component addition of another matrix.
-  Standard_NODISCARD NCollection_Mat3 Added(const NCollection_Mat3& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat3 Added(const NCollection_Mat3& theMat) const noexcept
   {
     NCollection_Mat3 aMat(*this);
     aMat += theMat;
@@ -343,13 +393,15 @@ public:
   }
 
   //! Per-component addition of another matrix.
-  Standard_NODISCARD NCollection_Mat3 operator+(const NCollection_Mat3& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat3 operator+(
+    const NCollection_Mat3& theMat) const noexcept
   {
     return Added(theMat);
   }
 
   //! Per-component subtraction of another matrix.
-  Standard_NODISCARD NCollection_Mat3 Subtracted(const NCollection_Mat3& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat3 Subtracted(
+    const NCollection_Mat3& theMat) const noexcept
   {
     NCollection_Mat3 aMat(*this);
     aMat -= theMat;
@@ -357,13 +409,14 @@ public:
   }
 
   //! Per-component subtraction of another matrix.
-  Standard_NODISCARD NCollection_Mat3 operator-(const NCollection_Mat3& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat3 operator-(
+    const NCollection_Mat3& theMat) const noexcept
   {
     return Subtracted(theMat);
   }
 
   //! Returns matrix with all components negated.
-  Standard_NODISCARD NCollection_Mat3 Negated() const
+  Standard_NODISCARD constexpr NCollection_Mat3 Negated() const noexcept
   {
     NCollection_Mat3 aMat;
     for (size_t i = 0; i < 9; ++i)
@@ -374,11 +427,11 @@ public:
   }
 
   //! Returns matrix with all components negated.
-  Standard_NODISCARD NCollection_Mat3 operator-() const { return Negated(); }
+  Standard_NODISCARD constexpr NCollection_Mat3 operator-() const noexcept { return Negated(); }
 
   //! Transpose the matrix.
   //! @return transposed copy of the matrix.
-  Standard_NODISCARD NCollection_Mat3 Transposed() const
+  Standard_NODISCARD constexpr NCollection_Mat3 Transposed() const noexcept
   {
     NCollection_Mat3 aTempMat;
     aTempMat.SetRow(0, GetColumn(0));
@@ -388,10 +441,10 @@ public:
   }
 
   //! Transpose the matrix.
-  void Transpose() { *this = Transposed(); }
+  constexpr void Transpose() noexcept { *this = Transposed(); }
 
   //! Return determinant of the matrix.
-  Element_t Determinant() const
+  constexpr Element_t Determinant() const noexcept
   {
     return (GetValue(0, 0) * GetValue(1, 1) * GetValue(2, 2)
             + GetValue(0, 1) * GetValue(1, 2) * GetValue(2, 0)
@@ -402,7 +455,7 @@ public:
   }
 
   //! Return adjoint (adjugate matrix, e.g. conjugate transpose).
-  Standard_NODISCARD NCollection_Mat3 Adjoint() const
+  Standard_NODISCARD constexpr NCollection_Mat3 Adjoint() const noexcept
   {
     NCollection_Mat3 aMat;
     aMat.SetRow(0, NCollection_Vec3<Element_t>::Cross(GetRow(1), GetRow(2)));
@@ -451,7 +504,7 @@ public:
 
   //! Take values from NCollection_Mat3 with a different element type with type conversion.
   template <typename Other_t>
-  void ConvertFrom(const NCollection_Mat3<Other_t>& theFrom)
+  constexpr void ConvertFrom(const NCollection_Mat3<Other_t>& theFrom) noexcept
   {
     for (int anIdx = 0; anIdx < 9; ++anIdx)
     {
@@ -460,13 +513,13 @@ public:
   }
 
   //! Maps plain C array to matrix type.
-  static NCollection_Mat3<Element_t>& Map(Element_t* theData)
+  static NCollection_Mat3<Element_t>& Map(Element_t* theData) noexcept
   {
     return *reinterpret_cast<NCollection_Mat3<Element_t>*>(theData);
   }
 
   //! Maps plain C array to matrix type.
-  static const NCollection_Mat3<Element_t>& Map(const Element_t* theData)
+  static const NCollection_Mat3<Element_t>& Map(const Element_t* theData) noexcept
   {
     return *reinterpret_cast<const NCollection_Mat3<Element_t>*>(theData);
   }
@@ -492,20 +545,14 @@ private:
   Element_t myMat[9];
 
 private:
-  static const Element_t MyZeroArray[9];
-  static const Element_t MyIdentityArray[9];
+  static constexpr Element_t MyZeroArray[9]     = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+  static constexpr Element_t MyIdentityArray[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
 
   // All instantiations are friend to each other
   template <class OtherType>
   friend class NCollection_Mat3;
 };
 
-template <typename Element_t>
-const Element_t NCollection_Mat3<Element_t>::MyZeroArray[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-template <typename Element_t>
-const Element_t NCollection_Mat3<Element_t>::MyIdentityArray[] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
-
 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
   #include <type_traits>
 
index f49a76d67e563ed3535b406edc498b8605c0ce28..55030b5cf18b41dae7ae0a4321456ea0a0e3dc1d 100755 (executable)
@@ -29,17 +29,17 @@ class NCollection_Mat4
 public:
   //! Get number of rows.
   //! @return number of rows.
-  static size_t Rows() { return 4; }
+  static constexpr size_t Rows() noexcept { return 4; }
 
   //! Get number of columns.
   //! @return number of columns.
-  static size_t Cols() { return 4; }
+  static constexpr size_t Cols() noexcept { return 4; }
 
   //! Return identity matrix.
-  static NCollection_Mat4 Identity() { return NCollection_Mat4(); }
+  static constexpr NCollection_Mat4 Identity() { return NCollection_Mat4(); }
 
   //! Return zero matrix.
-  static NCollection_Mat4 Zero()
+  static constexpr NCollection_Mat4 Zero()
   {
     NCollection_Mat4 aMat;
     aMat.InitZero();
@@ -49,7 +49,7 @@ public:
 public:
   //! Empty constructor.
   //! Construct the identity matrix.
-  NCollection_Mat4() { InitIdentity(); }
+  constexpr NCollection_Mat4() { InitIdentity(); }
 
   //! Conversion constructor (explicitly converts some 4 x 4 matrix with other element type
   //! to a new 4 x 4 matrix with the element type Element_t,
@@ -57,7 +57,7 @@ public:
   //! @tparam OtherElement_t the element type of the other 4 x 4 matrix theOtherVec4
   //! @param theOtherMat4 the 4 x 4 matrix that needs to be converted
   template <typename OtherElement_t>
-  explicit NCollection_Mat4(const NCollection_Mat4<OtherElement_t>& theOtherMat4)
+  explicit constexpr NCollection_Mat4(const NCollection_Mat4<OtherElement_t>& theOtherMat4) noexcept
   {
     ConvertFrom(theOtherMat4);
   }
@@ -66,7 +66,7 @@ public:
   //! @param[in] theRow  the row to address.
   //! @param[in] theCol  the column to address.
   //! @return the value of the addressed element.
-  Element_t GetValue(const size_t theRow, const size_t theCol) const
+  constexpr Element_t GetValue(const size_t theRow, const size_t theCol) const noexcept
   {
     return myMat[theCol * 4 + theRow];
   }
@@ -75,7 +75,7 @@ public:
   //! @param[in] theRow  the row to access.
   //! @param[in] theCol  the column to access.
   //! @return reference on the matrix element.
-  Element_t& ChangeValue(const size_t theRow, const size_t theCol)
+  constexpr Element_t& ChangeValue(const size_t theRow, const size_t theCol) noexcept
   {
     return myMat[theCol * 4 + theRow];
   }
@@ -84,19 +84,21 @@ public:
   //! @param[in] theRow    the row to change.
   //! @param[in] theCol    the column to change.
   //! @param[in] theValue  the value to set.
-  void SetValue(const size_t theRow, const size_t theCol, const Element_t theValue)
+  constexpr void SetValue(const size_t    theRow,
+                          const size_t    theCol,
+                          const Element_t theValue) noexcept
   {
     myMat[theCol * 4 + theRow] = theValue;
   }
 
   //! Return value.
-  Element_t& operator()(const size_t theRow, const size_t theCol)
+  constexpr Element_t& operator()(const size_t theRow, const size_t theCol) noexcept
   {
     return ChangeValue(theRow, theCol);
   }
 
   //! Return value.
-  Element_t operator()(const size_t theRow, const size_t theCol) const
+  constexpr Element_t operator()(const size_t theRow, const size_t theCol) const noexcept
   {
     return GetValue(theRow, theCol);
   }
@@ -104,7 +106,7 @@ public:
   //! Get vector of elements for the specified row.
   //! @param[in] theRow  the row to access.
   //! @return vector of elements.
-  NCollection_Vec4<Element_t> GetRow(const size_t theRow) const
+  constexpr NCollection_Vec4<Element_t> GetRow(const size_t theRow) const noexcept
   {
     return NCollection_Vec4<Element_t>(GetValue(theRow, 0),
                                        GetValue(theRow, 1),
@@ -115,7 +117,7 @@ public:
   //! Change first 3 row values by the passed vector.
   //! @param[in] theRow  the row to change.
   //! @param[in] theVec  the vector of values.
-  void SetRow(const size_t theRow, const NCollection_Vec3<Element_t>& theVec)
+  constexpr void SetRow(const size_t theRow, const NCollection_Vec3<Element_t>& theVec) noexcept
   {
     SetValue(theRow, 0, theVec.x());
     SetValue(theRow, 1, theVec.y());
@@ -125,7 +127,7 @@ public:
   //! Set row values by the passed 4 element vector.
   //! @param[in] theRow  the row to change.
   //! @param[in] theVec  the vector of values.
-  void SetRow(const size_t theRow, const NCollection_Vec4<Element_t>& theVec)
+  constexpr void SetRow(const size_t theRow, const NCollection_Vec4<Element_t>& theVec) noexcept
   {
     SetValue(theRow, 0, theVec.x());
     SetValue(theRow, 1, theVec.y());
@@ -136,7 +138,7 @@ public:
   //! Get vector of elements for the specified column.
   //! @param[in] theCol  the column to access.
   //! @return vector of elements.
-  NCollection_Vec4<Element_t> GetColumn(const size_t theCol) const
+  constexpr NCollection_Vec4<Element_t> GetColumn(const size_t theCol) const noexcept
   {
     return NCollection_Vec4<Element_t>(GetValue(0, theCol),
                                        GetValue(1, theCol),
@@ -147,7 +149,7 @@ public:
   //! Change first 3 column values by the passed vector.
   //! @param[in] theCol  the column to change.
   //! @param[in] theVec  the vector of values.
-  void SetColumn(const size_t theCol, const NCollection_Vec3<Element_t>& theVec)
+  constexpr void SetColumn(const size_t theCol, const NCollection_Vec3<Element_t>& theVec) noexcept
   {
     SetValue(0, theCol, theVec.x());
     SetValue(1, theCol, theVec.y());
@@ -157,7 +159,7 @@ public:
   //! Set column values by the passed 4 element vector.
   //! @param[in] theCol  the column to change.
   //! @param[in] theVec  the vector of values.
-  void SetColumn(const size_t theCol, const NCollection_Vec4<Element_t>& theVec)
+  constexpr void SetColumn(const size_t theCol, const NCollection_Vec4<Element_t>& theVec) noexcept
   {
     SetValue(0, theCol, theVec.x());
     SetValue(1, theCol, theVec.y());
@@ -167,7 +169,7 @@ public:
 
   //! Get vector of diagonal elements.
   //! @return vector of diagonal elements.
-  NCollection_Vec4<Element_t> GetDiagonal() const
+  constexpr NCollection_Vec4<Element_t> GetDiagonal() const noexcept
   {
     return NCollection_Vec4<Element_t>(GetValue(0, 0),
                                        GetValue(1, 1),
@@ -177,7 +179,7 @@ public:
 
   //! Change first 3 elements of the diagonal matrix.
   //! @param theVec the vector of values.
-  void SetDiagonal(const NCollection_Vec3<Element_t>& theVec)
+  constexpr void SetDiagonal(const NCollection_Vec3<Element_t>& theVec) noexcept
   {
     SetValue(0, 0, theVec.x());
     SetValue(1, 1, theVec.y());
@@ -186,7 +188,7 @@ public:
 
   //! Set diagonal elements of the matrix by the passed vector.
   //! @param[in] theVec  the vector of values.
-  void SetDiagonal(const NCollection_Vec4<Element_t>& theVec)
+  constexpr void SetDiagonal(const NCollection_Vec4<Element_t>& theVec) noexcept
   {
     SetValue(0, 0, theVec.x());
     SetValue(1, 1, theVec.y());
@@ -195,7 +197,7 @@ public:
   }
 
   //! Return 3x3 sub-matrix.
-  NCollection_Mat3<Element_t> GetMat3() const
+  constexpr NCollection_Mat3<Element_t> GetMat3() const noexcept
   {
     NCollection_Mat3<Element_t> aMat;
     aMat.SetColumn(0, GetColumn(0).xyz());
@@ -205,41 +207,84 @@ public:
   }
 
   //! Initialize the zero matrix.
-  void InitZero() { std::memcpy(this, MyZeroArray, sizeof(NCollection_Mat4)); }
+  constexpr void InitZero() noexcept
+  {
+    for (int i = 0; i < 16; ++i)
+    {
+      myMat[i] = MyZeroArray[i];
+    }
+  }
 
   //! Checks the matrix for zero (without tolerance).
-  bool IsZero() const { return std::memcmp(this, MyZeroArray, sizeof(NCollection_Mat4)) == 0; }
+  constexpr bool IsZero() const noexcept
+  {
+    for (int i = 0; i < 16; ++i)
+    {
+      if (myMat[i] != MyZeroArray[i])
+      {
+        return false;
+      }
+    }
+    return true;
+  }
 
   //! Initialize the identity matrix.
-  void InitIdentity() { std::memcpy(this, MyIdentityArray, sizeof(NCollection_Mat4)); }
+  constexpr void InitIdentity() noexcept
+  {
+    for (int i = 0; i < 16; ++i)
+    {
+      myMat[i] = MyIdentityArray[i];
+    }
+  }
 
   //! Checks the matrix for identity (without tolerance).
-  bool IsIdentity() const
+  constexpr bool IsIdentity() const noexcept
   {
-    return std::memcmp(this, MyIdentityArray, sizeof(NCollection_Mat4)) == 0;
+    for (int i = 0; i < 16; ++i)
+    {
+      if (myMat[i] != MyIdentityArray[i])
+      {
+        return false;
+      }
+    }
+    return true;
   }
 
   //! Check this matrix for equality with another matrix (without tolerance!).
-  bool IsEqual(const NCollection_Mat4& theOther) const
+  constexpr bool IsEqual(const NCollection_Mat4& theOther) const noexcept
   {
-    return std::memcmp(this, &theOther, sizeof(NCollection_Mat4)) == 0;
+    for (int i = 0; i < 16; ++i)
+    {
+      if (myMat[i] != theOther.myMat[i])
+      {
+        return false;
+      }
+    }
+    return true;
   }
 
   //! Check this matrix for equality with another matrix (without tolerance!).
-  bool operator==(const NCollection_Mat4& theOther) const { return IsEqual(theOther); }
+  constexpr bool operator==(const NCollection_Mat4& theOther) const noexcept
+  {
+    return IsEqual(theOther);
+  }
 
   //! Check this matrix for non-equality with another matrix (without tolerance!).
-  bool operator!=(const NCollection_Mat4& theOther) const { return !IsEqual(theOther); }
+  constexpr bool operator!=(const NCollection_Mat4& theOther) const noexcept
+  {
+    return !IsEqual(theOther);
+  }
 
   //! Raw access to the data (for OpenGL exchange);
   //! the data is returned in column-major order.
-  const Element_t* GetData() const { return myMat; }
+  constexpr const Element_t* GetData() const noexcept { return myMat; }
 
-  Element_t* ChangeData() { return myMat; }
+  constexpr Element_t* ChangeData() noexcept { return myMat; }
 
   //! Multiply by the vector (M * V).
   //! @param[in] theVec  the vector to multiply.
-  NCollection_Vec4<Element_t> operator*(const NCollection_Vec4<Element_t>& theVec) const
+  constexpr NCollection_Vec4<Element_t> operator*(
+    const NCollection_Vec4<Element_t>& theVec) const noexcept
   {
     return NCollection_Vec4<Element_t>(
       GetValue(0, 0) * theVec.x() + GetValue(0, 1) * theVec.y() + GetValue(0, 2) * theVec.z()
@@ -255,15 +300,15 @@ public:
   //! Compute matrix multiplication product: A * B.
   //! @param[in] theMatA  the matrix "A".
   //! @param[in] theMatB  the matrix "B".
-  static NCollection_Mat4 Multiply(const NCollection_Mat4& theMatA, const NCollection_Mat4& theMatB)
+  static constexpr NCollection_Mat4 Multiply(const NCollection_Mat4& theMatA,
+                                             const NCollection_Mat4& theMatB) noexcept
   {
     NCollection_Mat4 aMatRes;
 
-    size_t aInputElem;
     for (size_t aResElem = 0; aResElem < 16; ++aResElem)
     {
       aMatRes.myMat[aResElem] = (Element_t)0;
-      for (aInputElem = 0; aInputElem < 4; ++aInputElem)
+      for (size_t aInputElem = 0; aInputElem < 4; ++aInputElem)
       {
         aMatRes.myMat[aResElem] +=
           theMatA.GetValue(aResElem % 4, aInputElem) * theMatB.GetValue(aInputElem, aResElem / 4);
@@ -275,11 +320,14 @@ public:
 
   //! Compute matrix multiplication.
   //! @param[in] theMat  the matrix to multiply.
-  void Multiply(const NCollection_Mat4& theMat) { *this = Multiply(*this, theMat); }
+  constexpr void Multiply(const NCollection_Mat4& theMat) noexcept
+  {
+    *this = Multiply(*this, theMat);
+  }
 
   //! Multiply by the another matrix.
   //! @param[in] theMat  the other matrix.
-  NCollection_Mat4& operator*=(const NCollection_Mat4& theMat)
+  constexpr NCollection_Mat4& operator*=(const NCollection_Mat4& theMat) noexcept
   {
     Multiply(theMat);
     return *this;
@@ -288,7 +336,8 @@ public:
   //! Compute matrix multiplication product.
   //! @param[in] theMat  the other matrix.
   //! @return result of multiplication.
-  Standard_NODISCARD NCollection_Mat4 operator*(const NCollection_Mat4& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat4 operator*(
+    const NCollection_Mat4& theMat) const noexcept
   {
     return Multiplied(theMat);
   }
@@ -296,7 +345,8 @@ public:
   //! Compute matrix multiplication product.
   //! @param[in] theMat  the other matrix.
   //! @return result of multiplication.
-  Standard_NODISCARD NCollection_Mat4 Multiplied(const NCollection_Mat4& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat4 Multiplied(
+    const NCollection_Mat4& theMat) const noexcept
   {
     NCollection_Mat4 aTempMat(*this);
     aTempMat *= theMat;
@@ -305,7 +355,7 @@ public:
 
   //! Compute per-component multiplication.
   //! @param[in] theFactor  the scale factor.
-  void Multiply(const Element_t theFactor)
+  constexpr void Multiply(const Element_t theFactor) noexcept
   {
     for (size_t i = 0; i < 16; ++i)
     {
@@ -315,7 +365,7 @@ public:
 
   //! Compute per-element multiplication.
   //! @param[in] theFactor  the scale factor.
-  NCollection_Mat4& operator*=(const Element_t theFactor)
+  constexpr NCollection_Mat4& operator*=(const Element_t theFactor) noexcept
   {
     Multiply(theFactor);
     return *this;
@@ -324,7 +374,7 @@ public:
   //! Compute per-element multiplication.
   //! @param[in] theFactor  the scale factor.
   //! @return the result of multiplication.
-  Standard_NODISCARD NCollection_Mat4 operator*(const Element_t theFactor) const
+  Standard_NODISCARD constexpr NCollection_Mat4 operator*(const Element_t theFactor) const noexcept
   {
     return Multiplied(theFactor);
   }
@@ -332,7 +382,7 @@ public:
   //! Compute per-element multiplication.
   //! @param[in] theFactor  the scale factor.
   //! @return the result of multiplication.
-  Standard_NODISCARD NCollection_Mat4 Multiplied(const Element_t theFactor) const
+  Standard_NODISCARD constexpr NCollection_Mat4 Multiplied(const Element_t theFactor) const noexcept
   {
     NCollection_Mat4 aTempMat(*this);
     aTempMat *= theFactor;
@@ -341,7 +391,7 @@ public:
 
   //! Compute per-component division.
   //! @param[in] theFactor  the scale factor.
-  void Divide(const Element_t theFactor)
+  constexpr void Divide(const Element_t theFactor)
   {
     for (size_t i = 0; i < 16; ++i)
     {
@@ -351,14 +401,14 @@ public:
 
   //! Per-component division.
   //! @param[in] theScalar  the scale factor.
-  NCollection_Mat4& operator/=(const Element_t theScalar)
+  constexpr NCollection_Mat4& operator/=(const Element_t theScalar)
   {
     Divide(theScalar);
     return *this;
   }
 
   //! Divides all the coefficients of the matrix by scalar.
-  Standard_NODISCARD NCollection_Mat4 Divided(const Element_t theScalar) const
+  Standard_NODISCARD constexpr NCollection_Mat4 Divided(const Element_t theScalar) const
   {
     NCollection_Mat4 aTempMat(*this);
     aTempMat /= theScalar;
@@ -366,13 +416,13 @@ public:
   }
 
   //! Divides all the coefficients of the matrix by scalar.
-  Standard_NODISCARD NCollection_Mat4 operator/(const Element_t theScalar) const
+  Standard_NODISCARD constexpr NCollection_Mat4 operator/(const Element_t theScalar) const
   {
     return Divided(theScalar);
   }
 
   //! Per-component addition of another matrix.
-  void Add(const NCollection_Mat4& theMat)
+  constexpr void Add(const NCollection_Mat4& theMat) noexcept
   {
     for (size_t i = 0; i < 16; ++i)
     {
@@ -381,14 +431,14 @@ public:
   }
 
   //! Per-component addition of another matrix.
-  NCollection_Mat4& operator+=(const NCollection_Mat4& theMat)
+  constexpr NCollection_Mat4& operator+=(const NCollection_Mat4& theMat) noexcept
   {
     Add(theMat);
     return *this;
   }
 
   //! Per-component subtraction of another matrix.
-  void Subtract(const NCollection_Mat4& theMat)
+  constexpr void Subtract(const NCollection_Mat4& theMat) noexcept
   {
     for (size_t i = 0; i < 16; ++i)
     {
@@ -397,14 +447,14 @@ public:
   }
 
   //! Per-component subtraction of another matrix.
-  NCollection_Mat4& operator-=(const NCollection_Mat4& theMat)
+  constexpr NCollection_Mat4& operator-=(const NCollection_Mat4& theMat) noexcept
   {
     Subtract(theMat);
     return *this;
   }
 
   //! Per-component addition of another matrix.
-  Standard_NODISCARD NCollection_Mat4 Added(const NCollection_Mat4& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat4 Added(const NCollection_Mat4& theMat) const noexcept
   {
     NCollection_Mat4 aMat(*this);
     aMat += theMat;
@@ -412,13 +462,15 @@ public:
   }
 
   //! Per-component addition of another matrix.
-  Standard_NODISCARD NCollection_Mat4 operator+(const NCollection_Mat4& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat4 operator+(
+    const NCollection_Mat4& theMat) const noexcept
   {
     return Added(theMat);
   }
 
   //! Per-component subtraction of another matrix.
-  Standard_NODISCARD NCollection_Mat4 Subtracted(const NCollection_Mat4& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat4 Subtracted(
+    const NCollection_Mat4& theMat) const noexcept
   {
     NCollection_Mat4 aMat(*this);
     aMat -= theMat;
@@ -426,13 +478,14 @@ public:
   }
 
   //! Per-component subtraction of another matrix.
-  Standard_NODISCARD NCollection_Mat4 operator-(const NCollection_Mat4& theMat) const
+  Standard_NODISCARD constexpr NCollection_Mat4 operator-(
+    const NCollection_Mat4& theMat) const noexcept
   {
     return Subtracted(theMat);
   }
 
   //! Returns matrix with all components negated.
-  Standard_NODISCARD NCollection_Mat4 Negated() const
+  Standard_NODISCARD constexpr NCollection_Mat4 Negated() const noexcept
   {
     NCollection_Mat4 aMat;
     for (size_t i = 0; i < 16; ++i)
@@ -443,11 +496,11 @@ public:
   }
 
   //! Returns matrix with all components negated.
-  Standard_NODISCARD NCollection_Mat4 operator-() const { return Negated(); }
+  Standard_NODISCARD constexpr NCollection_Mat4 operator-() const noexcept { return Negated(); }
 
   //! Translate the matrix on the passed vector.
   //! @param[in] theVec  the translation vector.
-  void Translate(const NCollection_Vec3<Element_t>& theVec)
+  constexpr void Translate(const NCollection_Vec3<Element_t>& theVec) noexcept
   {
     NCollection_Mat4 aTempMat;
     aTempMat.SetColumn(3, theVec);
@@ -456,7 +509,7 @@ public:
 
   //! Transpose the matrix.
   //! @return transposed copy of the matrix.
-  Standard_NODISCARD NCollection_Mat4 Transposed() const
+  Standard_NODISCARD constexpr NCollection_Mat4 Transposed() const noexcept
   {
     NCollection_Mat4 aTempMat;
     aTempMat.SetRow(0, GetColumn(0));
@@ -467,7 +520,7 @@ public:
   }
 
   //! Transpose the matrix.
-  void Transpose() { *this = Transposed(); }
+  constexpr void Transpose() noexcept { *this = Transposed(); }
 
   //! Compute inverted matrix.
   //! @param[out] theOutMx  the inverted matrix
@@ -564,7 +617,7 @@ public:
   }
 
   //! Return determinant of the 3x3 sub-matrix.
-  Element_t DeterminantMat3() const
+  constexpr Element_t DeterminantMat3() const noexcept
   {
     return (GetValue(0, 0) * GetValue(1, 1) * GetValue(2, 2)
             + GetValue(0, 1) * GetValue(1, 2) * GetValue(2, 0)
@@ -575,7 +628,7 @@ public:
   }
 
   //! Return adjoint (adjugate matrix, e.g. conjugate transpose).
-  Standard_NODISCARD NCollection_Mat4<Element_t> Adjoint() const
+  Standard_NODISCARD constexpr NCollection_Mat4<Element_t> Adjoint() const noexcept
   {
     NCollection_Mat4<Element_t> aMat;
     aMat.SetRow(0, crossVec4(GetRow(1), GetRow(2), GetRow(3)));
@@ -587,7 +640,7 @@ public:
 
   //! Take values from NCollection_Mat4 with a different element type with type conversion.
   template <typename Other_t>
-  void ConvertFrom(const NCollection_Mat4<Other_t>& theFrom)
+  constexpr void ConvertFrom(const NCollection_Mat4<Other_t>& theFrom) noexcept
   {
     for (int anIdx = 0; anIdx < 16; ++anIdx)
     {
@@ -597,19 +650,19 @@ public:
 
   //! Take values from NCollection_Mat4 with a different element type with type conversion.
   template <typename Other_t>
-  void Convert(const NCollection_Mat4<Other_t>& theFrom)
+  constexpr void Convert(const NCollection_Mat4<Other_t>& theFrom) noexcept
   {
     ConvertFrom(theFrom);
   }
 
   //! Maps plain C array to matrix type.
-  static NCollection_Mat4<Element_t>& Map(Element_t* theData)
+  static NCollection_Mat4<Element_t>& Map(Element_t* theData) noexcept
   {
     return *reinterpret_cast<NCollection_Mat4<Element_t>*>(theData);
   }
 
   //! Maps plain C array to matrix type.
-  static const NCollection_Mat4<Element_t>& Map(const Element_t* theData)
+  static const NCollection_Mat4<Element_t>& Map(const Element_t* theData) noexcept
   {
     return *reinterpret_cast<const NCollection_Mat4<Element_t>*>(theData);
   }
@@ -640,9 +693,10 @@ public:
 
 private:
   //! Cross-product has no direct meaning in 4D space - provided for local usage.
-  static NCollection_Vec4<Element_t> crossVec4(const NCollection_Vec4<Element_t>& theA,
-                                               const NCollection_Vec4<Element_t>& theB,
-                                               const NCollection_Vec4<Element_t>& theC)
+  static constexpr NCollection_Vec4<Element_t> crossVec4(
+    const NCollection_Vec4<Element_t>& theA,
+    const NCollection_Vec4<Element_t>& theB,
+    const NCollection_Vec4<Element_t>& theC) noexcept
   {
     const Element_t aD1 = (theB.z() * theC.w()) - (theB.w() * theC.z());
     const Element_t aD2 = (theB.y() * theC.w()) - (theB.w() * theC.y());
@@ -663,22 +717,14 @@ private:
   Element_t myMat[16];
 
 private:
-  static const Element_t MyZeroArray[16];
-  static const Element_t MyIdentityArray[16];
+  static constexpr Element_t MyZeroArray[16]     = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+  static constexpr Element_t MyIdentityArray[16] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
 
   // All instantiations are friend to each other
   template <class OtherType>
   friend class NCollection_Mat4;
 };
 
-template <typename Element_t>
-const Element_t NCollection_Mat4<Element_t>::MyZeroArray[] =
-  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-template <typename Element_t>
-const Element_t NCollection_Mat4<Element_t>::MyIdentityArray[] =
-  {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
-
 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
   #include <type_traits>
 
index fb26c02b7e391d66f1bc15e649b50e17e5b2b593..fa91e507c4816084cfee0e0bb0d6a7f95cc2b595 100644 (file)
@@ -18,6 +18,7 @@
 #include <Standard.hxx>
 
 #include <memory>
+#include <type_traits>
 
 //! Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5.
 /*! The allocator uses a standard OCCT mechanism for memory
@@ -54,7 +55,7 @@ public:
   //! Constructor.
   //! Creates an object using the default Open CASCADE allocation mechanism, i.e., which uses
   //! Standard::Allocate() and Standard::Free() underneath.
-  NCollection_OccAllocator()
+  NCollection_OccAllocator() noexcept
       : myAllocator(nullptr)
   {
   }
@@ -116,7 +117,7 @@ public:
 
   void SetAllocator(const Handle(NCollection_BaseAllocator)& theAlloc) { myAllocator = theAlloc; }
 
-  const Handle(NCollection_BaseAllocator)& Allocator() const { return myAllocator; }
+  const Handle(NCollection_BaseAllocator)& Allocator() const noexcept { return myAllocator; }
 
   //! Allocates memory for theSize objects.
   pointer allocate(size_type theSize, const void* = 0)
@@ -149,15 +150,15 @@ public:
   }
 
   //! Returns an object address.
-  pointer address(reference theItem) const { return &theItem; }
+  pointer address(reference theItem) const noexcept { return &theItem; }
 
   //! Returns an object address.
-  const_pointer address(const_reference theItem) const { return &theItem; }
+  const_pointer address(const_reference theItem) const noexcept { return &theItem; }
 
   //! Destroys the object.
   //! Uses the object destructor.
   template <class _Uty>
-  void destroy(_Uty* _Ptr)
+  void destroy(_Uty* _Ptr) noexcept(std::is_nothrow_destructible<_Uty>::value)
   {
     (void)_Ptr;
     _Ptr->~_Uty();
@@ -166,24 +167,24 @@ public:
   //! Estimate maximum array size
   size_t max_size() const noexcept { return ((size_t)(-1) / sizeof(ItemType)); }
 
-  bool operator==(const NCollection_OccAllocator& theOther) const
+  bool operator==(const NCollection_OccAllocator& theOther) const noexcept
   {
     return theOther.Allocator() == myAllocator;
   }
 
   template <class U>
-  bool operator==(const NCollection_OccAllocator<U>& theOther) const
+  bool operator==(const NCollection_OccAllocator<U>& theOther) const noexcept
   {
     return theOther.Allocator() == myAllocator;
   }
 
-  bool operator!=(const NCollection_OccAllocator& theOther) const
+  bool operator!=(const NCollection_OccAllocator& theOther) const noexcept
   {
     return theOther.Allocator() != myAllocator;
   }
 
   template <class U>
-  bool operator!=(const NCollection_OccAllocator<U>& theOther) const
+  bool operator!=(const NCollection_OccAllocator<U>& theOther) const noexcept
   {
     return theOther.Allocator() != myAllocator;
   }
@@ -194,7 +195,7 @@ private:
 
 template <class U, class V>
 bool operator==(const NCollection_OccAllocator<U>& theFirst,
-                const NCollection_OccAllocator<V>& theSecond)
+                const NCollection_OccAllocator<V>& theSecond) noexcept
 {
   return theFirst.Allocator() == theSecond.Allocator();
 }
index 850b06778daf7a3cf8f52904658f77cb2df0aebc..b13d4bf125f3a1dde524620dc4cfbe71a87fd9bc 100644 (file)
@@ -36,12 +36,13 @@ constexpr std::array<int, 24> THE_PRIME_VECTOR = {
   17915905, 35831809, 71663617, 150994945, 301989889, 573308929, 1019215873, 2038431745};
 } // namespace
 
-int NCollection_Primes::NextPrimeForMap(const int theN)
+int NCollection_Primes::NextPrimeForMap(const int theN) noexcept
 {
   auto aResult = std::lower_bound(THE_PRIME_VECTOR.begin(), THE_PRIME_VECTOR.end(), theN + 1);
   if (aResult == THE_PRIME_VECTOR.end())
   {
-    throw Standard_OutOfRange("NCollection_Primes::NextPrimeForMap() - requested too big size");
+    // Return theN + 1 if requested size exceeds the largest available prime
+    return theN + 1;
   }
   return *aResult;
 }
index fdc8360deba93be13743790e49d34ebe54977792..95b0569bd94049a8c4ca13c00392f7affd8d3891 100644 (file)
@@ -31,7 +31,8 @@
 namespace NCollection_Primes
 {
 //! Returns the next prime number greater than or equal to theN.
-Standard_EXPORT int NextPrimeForMap(const int theN);
+//! If theN exceeds the largest available prime, returns theN + 1.
+Standard_EXPORT int NextPrimeForMap(const int theN) noexcept;
 }; // namespace NCollection_Primes
 
 #endif // _NCollection_Primes_HeaderFile
\ No newline at end of file
index 47ea1499fff3f557f85020b6a2334effd32b3ab7..b2658f8eb99fe709e3a85676eb4a03df9c344811 100644 (file)
@@ -54,10 +54,10 @@ public:
     }
 
     //! Constant value access
-    const TheItemType& Value() const { return myValue; }
+    const TheItemType& Value() const noexcept { return myValue; }
 
     //! Variable value access
-    TheItemType& ChangeValue() { return myValue; }
+    TheItemType& ChangeValue() noexcept { return myValue; }
 
   private:
     TheItemType myValue;
@@ -78,10 +78,10 @@ public:
     }
 
     //! Check end
-    Standard_Boolean More(void) const { return (myCurrent != NULL); }
+    Standard_Boolean More(void) const noexcept { return (myCurrent != NULL); }
 
     //! Make step
-    void Next(void)
+    void Next(void) noexcept
     {
       if (myCurrent)
       {
@@ -91,13 +91,13 @@ public:
     }
 
     //! Constant value access
-    const TheItemType& Value(void) const { return ((const Node*)myCurrent)->Value(); }
+    const TheItemType& Value(void) const noexcept { return ((const Node*)myCurrent)->Value(); }
 
     //! Variable value access
-    TheItemType& ChangeValue(void) const { return ((Node*)myCurrent)->ChangeValue(); }
+    TheItemType& ChangeValue(void) const noexcept { return ((Node*)myCurrent)->ChangeValue(); }
 
     //! Performs comparison of two iterators.
-    Standard_Boolean IsEqual(const Iterator& theOther) const
+    Standard_Boolean IsEqual(const Iterator& theOther) const noexcept
     {
       return myCurrent == theOther.myCurrent;
     }
@@ -112,10 +112,10 @@ public:
     const_iterator;
 
   //! Returns an iterator pointing to the first element in the sequence.
-  iterator begin() const { return Iterator(*this, true); }
+  iterator begin() const noexcept { return Iterator(*this, true); }
 
   //! Returns an iterator referring to the past-the-end element in the sequence.
-  iterator end() const
+  iterator end() const noexcept
   {
     Iterator anIter(*this, false);
     anIter.Next();
@@ -123,10 +123,10 @@ public:
   }
 
   //! Returns a const iterator pointing to the first element in the sequence.
-  const_iterator cbegin() const { return Iterator(*this, true); }
+  const_iterator cbegin() const noexcept { return Iterator(*this, true); }
 
   //! Returns a const iterator referring to the past-the-end element in the sequence.
-  const_iterator cend() const
+  const_iterator cend() const noexcept
   {
     Iterator anIter(*this, false);
     anIter.Next();
@@ -163,21 +163,21 @@ public:
   }
 
   //! Number of items
-  Standard_Integer Size(void) const { return mySize; }
+  Standard_Integer Size(void) const noexcept { return mySize; }
 
   //! Number of items
-  Standard_Integer Length(void) const { return mySize; }
+  Standard_Integer Length(void) const noexcept { return mySize; }
 
   //! Method for consistency with other collections.
   //! @return Lower bound (inclusive) for iteration.
-  Standard_Integer Lower() const { return 1; }
+  static constexpr Standard_Integer Lower() noexcept { return 1; }
 
   //! Method for consistency with other collections.
   //! @return Upper bound (inclusive) for iteration.
-  Standard_Integer Upper() const { return mySize; }
+  Standard_Integer Upper() const noexcept { return mySize; }
 
   //! Empty query
-  Standard_Boolean IsEmpty(void) const { return (mySize == 0); }
+  Standard_Boolean IsEmpty(void) const noexcept { return (mySize == 0); }
 
   //! Reverse sequence
   void Reverse(void) { PReverse(); }
index d946ab65f49fda40c62940b5a0a6d1deb35cd794..d38da033834f60c39d42be1f16738fbcfb823063 100644 (file)
@@ -48,7 +48,7 @@ class NCollection_SparseArray : public NCollection_SparseArrayBase
 {
 public:
   //! Constructor; accepts size of blocks
-  explicit NCollection_SparseArray(Standard_Size theIncrement)
+  explicit NCollection_SparseArray(Standard_Size theIncrement) noexcept
       : NCollection_SparseArrayBase(sizeof(TheItemType), theIncrement)
   {
   }
@@ -103,10 +103,10 @@ public:
   //!@{
 
   //! Returns number of items in the array
-  Standard_Size Extent() const { return Size(); }
+  Standard_Size Extent() const noexcept { return Size(); }
 
   //! Returns True if array is empty
-  Standard_Boolean IsEmpty() const { return Size() == 0; }
+  Standard_Boolean IsEmpty() const noexcept { return Size() == 0; }
 
   //! Direct const access to the item
   const TheItemType& Find(const Standard_Size theIndex) const { return Value(theIndex); }
@@ -156,7 +156,7 @@ public:
     const TheItemType& operator()(void) const { return *(const TheItemType*)this->value(); }
 
     //! Access current index with 'a-la map' interface
-    Standard_Size Key(void) const { return Index(); }
+    Standard_Size Key(void) const noexcept { return Index(); }
   };
 
   /**
index 02eca2a6c1e344e8e6c75f2aceb6fe27f0f4bdbc..1c3f479ec78b7cb84befd4dff9be5ed9c6eb4b4f 100644 (file)
 #define NCollection_SparseArrayBase_HeaderFile
 
 #include <Standard.hxx>
+#include <Standard_TypeDef.hxx>
 #include <Standard_OutOfRange.hxx>
 
-typedef size_t Standard_Size;
-
 /**
  * Base class for NCollection_SparseArray;
  * provides non-template implementation of general mechanics
@@ -37,7 +36,7 @@ public:
   Standard_EXPORT void Clear();
 
   //! Returns number of currently contained items
-  Standard_Size Size() const { return mySize; }
+  Standard_Size Size() const noexcept { return mySize; }
 
   //! Check whether the value at given index is set
   Standard_EXPORT Standard_Boolean HasValue(const Standard_Size theIndex) const;
@@ -72,7 +71,7 @@ private:
     typedef unsigned char Cell; //!< type of items used to hold bits
 
     //! Number of bits in each cell
-    static Standard_Size BitsPerCell() { return sizeof(Cell) * 8; }
+    static constexpr Standard_Size BitsPerCell() noexcept { return sizeof(Cell) * 8; }
 
   public:
     //! Initializes the block by pointer to block data
@@ -86,7 +85,8 @@ private:
     }
 
     //! Compute required size for block data, in bytes
-    static Standard_Size Size(const Standard_Size theNbItems, const Standard_Size theItemSize)
+    static constexpr Standard_Size Size(const Standard_Size theNbItems,
+                                        const Standard_Size theItemSize) noexcept
     {
       return sizeof(Standard_Size)
              + sizeof(Cell) * ((theNbItems + BitsPerCell() - 1) / BitsPerCell())
@@ -96,7 +96,7 @@ private:
     //! Returns address of array from address of block
     static char* ToArray(const Standard_Address theAddress,
                          const Standard_Size /*theNbItems*/,
-                         const Standard_Size /*theItemSize*/)
+                         const Standard_Size /*theItemSize*/) noexcept
     {
       return (char*)theAddress + sizeof(Standard_Size);
     }
@@ -104,7 +104,7 @@ private:
   public:
     //! Set bit for i-th item; returns non-null if that bit has
     //! not been set previously
-    Cell Set(Standard_Size i)
+    Cell Set(Standard_Size i) noexcept
     {
       Cell* abyte = Bits + i / BitsPerCell();
       Cell  amask = (Cell)('\1' << (i % BitsPerCell()));
@@ -114,7 +114,7 @@ private:
     }
 
     //! Check bit for i-th item; returns non-null if that bit is set
-    Cell IsSet(Standard_Size i)
+    Cell IsSet(Standard_Size i) noexcept
     {
       Cell* abyte = Bits + i / BitsPerCell();
       Cell  amask = (Cell)('\1' << (i % BitsPerCell()));
@@ -123,7 +123,7 @@ private:
 
     //! Unset bit for i-th item; returns non-null if that bit
     //! has been set previously
-    Cell Unset(Standard_Size i)
+    Cell Unset(Standard_Size i) noexcept
     {
       Cell* abyte = Bits + i / BitsPerCell();
       Cell  amask = (Cell)('\1' << (i % BitsPerCell()));
@@ -152,13 +152,13 @@ public:
     void Restart() { init(myArr); }
 
     //! Returns True if current item is available
-    Standard_Boolean More() const { return myHasMore; }
+    Standard_Boolean More() const noexcept { return myHasMore; }
 
     //! Advances to the next item
     Standard_EXPORT void Next();
 
     //! Returns current index
-    Standard_Size Index() const { return myIBlock * myArr->myBlockSize + myInd; }
+    Standard_Size Index() const noexcept { return myIBlock * myArr->myBlockSize + myInd; }
 
   protected:
     // Methods for descendant
@@ -170,7 +170,7 @@ public:
     Standard_EXPORT void init(const NCollection_SparseArrayBase* theArray);
 
     //! Returns address of the current item
-    Standard_Address value() const { return myArr->getItem(myBlock, myInd); }
+    Standard_Address value() const noexcept { return myArr->getItem(myBlock, myInd); }
 
   private:
     const NCollection_SparseArrayBase* myArr;
@@ -190,7 +190,7 @@ protected:
   // Object life
 
   //! Constructor; initialized by size of item and of block (in items)
-  NCollection_SparseArrayBase(Standard_Size theItemSize, Standard_Size theBlockSize)
+  NCollection_SparseArrayBase(Standard_Size theItemSize, Standard_Size theBlockSize) noexcept
       : myItemSize(theItemSize),
         myBlockSize(theBlockSize),
         myNbBlocks(0),
@@ -206,13 +206,13 @@ protected:
   // Data access interface for descendants
 
   //! Creates Block structure for block pointed by theAddr
-  Block getBlock(const Standard_Address theAddr) const
+  Block getBlock(const Standard_Address theAddr) const noexcept
   {
     return Block(theAddr, myBlockSize, myItemSize);
   }
 
   //! Find address of the item in the block by index (in the block)
-  Standard_Address getItem(const Block& theBlock, Standard_Size theInd) const
+  Standard_Address getItem(const Block& theBlock, Standard_Size theInd) const noexcept
   {
     return ((char*)theBlock.Array) + myItemSize * theInd;
   }
index 59283bb2081b5ca61f98d649dc605264e519f7f0..a7803e2696d78bb4b31c21adc4564ebe47b0fd75 100644 (file)
@@ -61,10 +61,10 @@ public:
   }
 
   //! Access to NCollection iterator instance
-  const BaseIterator& Iterator() const { return myIterator; }
+  const BaseIterator& Iterator() const noexcept { return myIterator; }
 
   //! Access to NCollection iterator instance
-  BaseIterator& ChangeIterator() { return myIterator; }
+  BaseIterator& ChangeIterator() noexcept { return myIterator; }
 
 protected: //! @name methods related to forward STL iterator
   // Note: Here we use SFINAE (Substitution failure is not an error) to choose
index 3757c4b6084b4289b36486b1b6a23a058338c28b..15c56448006a0db05a4110075c06417220ba6fa6 100644 (file)
@@ -29,41 +29,41 @@ class NCollection_TListIterator : public NCollection_BaseList::Iterator
 {
 public:
   //! Empty constructor - for later Init
-  NCollection_TListIterator(void)
+  NCollection_TListIterator(void) noexcept
       : NCollection_BaseList::Iterator()
   {
   }
 
   //! Constructor with initialisation
-  NCollection_TListIterator(const NCollection_BaseList& theList)
+  NCollection_TListIterator(const NCollection_BaseList& theList) noexcept
       : NCollection_BaseList::Iterator(theList)
   {
   }
 
   //! Check end
-  Standard_Boolean More(void) const { return (myCurrent != NULL); }
+  Standard_Boolean More(void) const noexcept { return (myCurrent != NULL); }
 
   //! Make step
-  void Next(void)
+  void Next(void) noexcept
   {
     myPrevious = myCurrent;
     myCurrent  = myCurrent->Next();
   }
 
   //! Constant Value access
-  const TheItemType& Value(void) const
+  const TheItemType& Value(void) const noexcept
   {
     return ((const NCollection_TListNode<TheItemType>*)myCurrent)->Value();
   }
 
   //! Non-const Value access
-  TheItemType& Value(void)
+  TheItemType& Value(void) noexcept
   {
     return ((NCollection_TListNode<TheItemType>*)myCurrent)->ChangeValue();
   }
 
   //! Non-const Value access
-  TheItemType& ChangeValue(void) const
+  TheItemType& ChangeValue(void) const noexcept
   {
     return ((NCollection_TListNode<TheItemType>*)myCurrent)->ChangeValue();
   }
index cbddb3ff578bd115b433c01b24e76e0ea4803c30..691568ce97b41def9bd8664e0569316d002fe88f 100644 (file)
@@ -41,10 +41,10 @@ public:
   }
 
   //! Constant value access
-  const TheItemType& Value() const { return myValue; }
+  const TheItemType& Value() const noexcept { return myValue; }
 
   //! Variable value access
-  TheItemType& ChangeValue() { return myValue; }
+  TheItemType& ChangeValue() noexcept { return myValue; }
 
   //! Static deleter to be passed to BaseList
   static void delNode(NCollection_ListNode* theNode, Handle(NCollection_BaseAllocator)& theAl)
diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_TypeDef.hxx b/src/FoundationClasses/TKernel/NCollection/NCollection_TypeDef.hxx
deleted file mode 100644 (file)
index 6c22caf..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Created on: 2005-08-24
-// Created by: ABV
-// Copyright (c) 2005-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Purpose:     Defines some portability macros
-
-#ifndef NCollection_TypeDef_HeaderFile
-#define NCollection_TypeDef_HeaderFile
-
-// Macro TYPENAME - either C++ keyword typename, or empty on
-// platforms that do not support it
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
-  // work-around against obsolete SUN WorkShop 5.3 compiler
-  #define TYPENAME
-#else
-  #define TYPENAME typename
-#endif
-
-#endif
index bf98c4a8094ad9402ae50c6401eb67181eb79cac..b1f48c26de3461017c12eca06bf75e41cc70a1b9 100644 (file)
@@ -106,7 +106,7 @@ public:
      * @return
      *   True signals that the selection process is stopped
      */
-    Standard_Boolean Stop() const { return myStop; }
+    Standard_Boolean Stop() const noexcept { return myStop; }
 
     /**
      * Destructor
@@ -143,23 +143,23 @@ public:
     {
     }
 
-    Standard_Boolean IsLeaf() const { return !myChildren; }
+    Standard_Boolean IsLeaf() const noexcept { return !myChildren; }
 
-    Standard_Boolean IsRoot() const { return !myParent; }
+    Standard_Boolean IsRoot() const noexcept { return !myParent; }
 
-    const TheBndType& Bnd() const { return myBnd; }
+    const TheBndType& Bnd() const noexcept { return myBnd; }
 
-    TheBndType& ChangeBnd() { return myBnd; }
+    TheBndType& ChangeBnd() noexcept { return myBnd; }
 
-    const TheObjType& Object() const { return myObject; }
+    const TheObjType& Object() const noexcept { return myObject; }
 
-    const TreeNode& Child(const Standard_Integer i) const { return myChildren[i]; }
+    const TreeNode& Child(const Standard_Integer i) const noexcept { return myChildren[i]; }
 
-    TreeNode& ChangeChild(const Standard_Integer i) { return myChildren[i]; }
+    TreeNode& ChangeChild(const Standard_Integer i) noexcept { return myChildren[i]; }
 
-    const TreeNode& Parent() const { return *myParent; }
+    const TreeNode& Parent() const noexcept { return *myParent; }
 
-    TreeNode& ChangeParent() { return *myParent; }
+    TreeNode& ChangeParent() noexcept { return *myParent; }
 
     /**
      * Forces *this node being gemmated such a way that it becomes
@@ -322,13 +322,13 @@ public:
       myAlloc = aNewAlloc;
   }
 
-  Standard_Boolean IsEmpty() const { return !myRoot; }
+  Standard_Boolean IsEmpty() const noexcept { return !myRoot; }
 
   /**
    * @return
    *   the root node of the tree
    */
-  const TreeNode& Root() const { return *myRoot; }
+  const TreeNode& Root() const noexcept { return *myRoot; }
 
   /**
    * Destructor.
@@ -340,7 +340,7 @@ public:
    * @return
    *   Allocator object used in this instance of UBTree.
    */
-  const Handle(NCollection_BaseAllocator)& Allocator() const { return myAlloc; }
+  const Handle(NCollection_BaseAllocator)& Allocator() const noexcept { return myAlloc; }
 
 protected:
   // ---------- PROTECTED METHODS ----------
@@ -349,7 +349,7 @@ protected:
    * @return
    *   the last added node
    */
-  TreeNode& ChangeLastNode() { return *myLastNode; }
+  TreeNode& ChangeLastNode() noexcept { return *myLastNode; }
 
   /**
    * Searches in the branch all objects conforming to the given selector.
@@ -514,7 +514,7 @@ Standard_Integer NCollection_UBTree<TheObjType, TheBndType>::Select(const TreeNo
       ChangeTree().Clear();                                                                        \
     }                                                                                              \
                                                                                                    \
-    Standard_Boolean IsEmpty() const                                                               \
+    Standard_Boolean IsEmpty() const noexcept                                                      \
     {                                                                                              \
       return Tree().IsEmpty();                                                                     \
     }                                                                                              \
@@ -526,11 +526,11 @@ Standard_Integer NCollection_UBTree<TheObjType, TheBndType>::Select(const TreeNo
                                                                                                    \
     /* Access to the tree algorithm */                                                             \
                                                                                                    \
-    const UBTree& Tree() const                                                                     \
+    const UBTree& Tree() const noexcept                                                            \
     {                                                                                              \
       return *myTree;                                                                              \
     }                                                                                              \
-    UBTree& ChangeTree()                                                                           \
+    UBTree& ChangeTree() noexcept                                                                  \
     {                                                                                              \
       return *myTree;                                                                              \
     }                                                                                              \
index 0092b979dba54b178c56a230fa3c3e58c8053cca..187692a3b22e070c879eb2c47a997bb176a9e061 100644 (file)
@@ -127,9 +127,8 @@ public:
   }
 
 private:
-  // Assignment operator is made empty and private in order to
-  // avoid warning on MSVC (C4512)
-  void operator=(const NCollection_UBTreeFiller&) {}
+  // Explicitly delete assignment operator
+  NCollection_UBTreeFiller& operator=(const NCollection_UBTreeFiller&) = delete;
 
   static Standard_Real checkNode(const UBTreeNode&      theNode,
                                  const Standard_Integer theLength,
index d2f7b3c879cabe0a08e44c91be38644c97e4f0a3..4dba4d5d91dc667aaf3505f5048e40ca0533da80 100755 (executable)
@@ -79,30 +79,30 @@ public:
   }
 
   //! Equality operator.
-  bool operator==(const NCollection_UtfIterator& theRight) const
+  constexpr bool operator==(const NCollection_UtfIterator& theRight) const noexcept
   {
     return myPosition == theRight.myPosition;
   }
 
   //! Return true if Unicode symbol is within valid range.
-  bool IsValid() const { return myCharUtf32 <= UTF32_MAX_LEGAL; }
+  constexpr bool IsValid() const noexcept { return myCharUtf32 <= UTF32_MAX_LEGAL; }
 
   //! Dereference operator.
   //! @return the UTF-32 codepoint of the symbol currently pointed by iterator.
-  Standard_Utf32Char operator*() const { return myCharUtf32; }
+  constexpr Standard_Utf32Char operator*() const noexcept { return myCharUtf32; }
 
   //! Buffer-fetching getter.
-  const Type* BufferHere() const { return myPosition; }
+  constexpr const Type* BufferHere() const noexcept { return myPosition; }
 
   //! Buffer-fetching getter. Dangerous! Iterator should be reinitialized on buffer change.
-  Type* ChangeBufferHere() { return (Type*)myPosition; }
+  Type* ChangeBufferHere() noexcept { return (Type*)myPosition; }
 
   //! Buffer-fetching getter.
-  const Type* BufferNext() const { return myPosNext; }
+  constexpr const Type* BufferNext() const noexcept { return myPosNext; }
 
   //! @return the index displacement from iterator initialization
   //!         (first symbol has index 0)
-  Standard_Integer Index() const { return myCharIndex; }
+  constexpr Standard_Integer Index() const noexcept { return myCharIndex; }
 
   //! @return the advance in bytes to store current symbol in UTF-8.
   //! 0 means an invalid symbol;
@@ -123,7 +123,7 @@ public:
 
   //! @return the advance in bytes to store current symbol in UTF-32.
   //! Always 4 bytes (method for consistency).
-  Standard_Integer AdvanceBytesUtf32() const
+  constexpr Standard_Integer AdvanceBytesUtf32() const noexcept
   {
     return Standard_Integer(sizeof(Standard_Utf32Char));
   }
@@ -198,14 +198,17 @@ private:
 
   void readNext(const Standard_Utf16Char*) { readUTF16(); }
 
-  void readNext(const Standard_Utf32Char*) { myCharUtf32 = *myPosNext++; }
+  void readNext(const Standard_Utf32Char*) noexcept { myCharUtf32 = *myPosNext++; }
 
   //! Helper overload methods to dispatch advance function depending on code unit size
   Standard_Integer advanceBytes(const Standard_Utf8Char*) const { return AdvanceBytesUtf8(); }
 
   Standard_Integer advanceBytes(const Standard_Utf16Char*) const { return AdvanceBytesUtf16(); }
 
-  Standard_Integer advanceBytes(const Standard_Utf32Char*) const { return AdvanceBytesUtf32(); }
+  constexpr Standard_Integer advanceBytes(const Standard_Utf32Char*) const noexcept
+  {
+    return AdvanceBytesUtf32();
+  }
 
   //! Helper overload methods to dispatch getter function depending on code unit size
   Standard_Utf8Char* getUtf(Standard_Utf8Char* theBuffer) const { return GetUtf8(theBuffer); }
@@ -215,20 +218,38 @@ private:
   Standard_Utf32Char* getUtf(Standard_Utf32Char* theBuffer) const { return GetUtf32(theBuffer); }
 
 private: //! @name unicode magic numbers
-  static const unsigned char      UTF8_BYTES_MINUS_ONE[256];
-  static const Standard_Utf32Char offsetsFromUTF8[6];
-  static const unsigned char      UTF8_FIRST_BYTE_MARK[7];
-  static const Standard_Utf32Char UTF8_BYTE_MASK;
-  static const Standard_Utf32Char UTF8_BYTE_MARK;
-  static const Standard_Utf32Char UTF16_SURROGATE_HIGH_START;
-  static const Standard_Utf32Char UTF16_SURROGATE_HIGH_END;
-  static const Standard_Utf32Char UTF16_SURROGATE_LOW_START;
-  static const Standard_Utf32Char UTF16_SURROGATE_LOW_END;
-  static const Standard_Utf32Char UTF16_SURROGATE_HIGH_SHIFT;
-  static const Standard_Utf32Char UTF16_SURROGATE_LOW_BASE;
-  static const Standard_Utf32Char UTF16_SURROGATE_LOW_MASK;
-  static const Standard_Utf32Char UTF32_MAX_BMP;
-  static const Standard_Utf32Char UTF32_MAX_LEGAL;
+  //! The first character in a UTF-8 sequence indicates how many bytes to read (among other things).
+  static constexpr unsigned char UTF8_BYTES_MINUS_ONE[256] = {
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5};
+
+  //! Magic values subtracted from a buffer value during UTF-8 conversion.
+  //! This table contains as many values as there might be trailing bytes in a UTF-8 sequence.
+  static constexpr Standard_Utf32Char offsetsFromUTF8[6] =
+    {0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, 0xFA082080UL, 0x82082080UL};
+
+  //! The first character in a UTF-8 sequence indicates how many bytes to read.
+  static constexpr unsigned char UTF8_FIRST_BYTE_MARK[7] =
+    {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
+
+  // Magic numbers for UTF encoding/decoding
+  static constexpr Standard_Utf32Char UTF8_BYTE_MASK             = 0xBF;
+  static constexpr Standard_Utf32Char UTF8_BYTE_MARK             = 0x80;
+  static constexpr Standard_Utf32Char UTF16_SURROGATE_HIGH_START = 0xD800;
+  static constexpr Standard_Utf32Char UTF16_SURROGATE_HIGH_END   = 0xDBFF;
+  static constexpr Standard_Utf32Char UTF16_SURROGATE_LOW_START  = 0xDC00;
+  static constexpr Standard_Utf32Char UTF16_SURROGATE_LOW_END    = 0xDFFF;
+  static constexpr Standard_Utf32Char UTF16_SURROGATE_HIGH_SHIFT = 10;
+  static constexpr Standard_Utf32Char UTF16_SURROGATE_LOW_BASE   = 0x0010000UL;
+  static constexpr Standard_Utf32Char UTF16_SURROGATE_LOW_MASK   = 0x3FFUL;
+  static constexpr Standard_Utf32Char UTF32_MAX_BMP              = 0x0000FFFFUL;
+  static constexpr Standard_Utf32Char UTF32_MAX_LEGAL            = 0x0010FFFFUL;
 
 private:                          //! @name private fields
   const Type*        myPosition;  //!< buffer position of the first element in the current symbol
index 6c134be1ab9d1c540d7441d8c11880f98d03c7a8..de4a877c12d580407a859590e89cdb4865361849 100755 (executable)
 // for internal or external distribution as long as this notice
 // remains attached.
 
-//! The first character in a UTF-8 sequence indicates how many bytes
-//! to read (among other things).
-template <typename Type>
-const unsigned char NCollection_UtfIterator<Type>::UTF8_BYTES_MINUS_ONE[256] = {
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5};
-
-//! Magic values subtracted from a buffer value during UTF-8 conversion.
-//! This table contains as many values as there might be trailing bytes
-//! in a UTF-8 sequence.
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::offsetsFromUTF8[6] =
-  {0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, 0xFA082080UL, 0x82082080UL};
-
-//! The first character in a UTF-8 sequence indicates how many bytes to read.
-template <typename Type>
-const unsigned char NCollection_UtfIterator<Type>::UTF8_FIRST_BYTE_MARK[7] =
-  {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
-
 // =======================================================================
 // function : readUTF8
 // purpose  : Get a UTF-8 character; leave the tracking pointer at the start of the next character.
@@ -101,30 +76,6 @@ inline void NCollection_UtfIterator<Type>::readUTF8()
   myPosNext = (Type*)aPos;
 }
 
-// magic numbers
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF8_BYTE_MASK = 0xBF;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF8_BYTE_MARK = 0x80;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_START = 0xD800;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_END = 0xDBFF;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_START = 0xDC00;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_END = 0xDFFF;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_HIGH_SHIFT = 10;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_BASE = 0x0010000UL;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF16_SURROGATE_LOW_MASK = 0x3FFUL;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF32_MAX_BMP = 0x0000FFFFUL;
-template <typename Type>
-const Standard_Utf32Char NCollection_UtfIterator<Type>::UTF32_MAX_LEGAL = 0x0010FFFFUL;
-
 //=================================================================================================
 
 template <typename Type>
index b54a2536e4cc55a6d23aef387bbcae96fe4b8eb6..56b6ff549611db94fef5c3dc89c03e9160798ebc 100755 (executable)
@@ -38,10 +38,10 @@ public:
   NCollection_UtfIterator<Type> Iterator() const { return NCollection_UtfIterator<Type>(myString); }
 
   //! @return the size of the buffer in bytes, excluding NULL-termination symbol
-  Standard_Integer Size() const { return mySize; }
+  Standard_Integer Size() const noexcept { return mySize; }
 
   //! @return the length of the string in Unicode symbols
-  Standard_Integer Length() const { return myLength; }
+  Standard_Integer Length() const noexcept { return myLength; }
 
   //! Retrieve Unicode symbol at specified position.
   //! Warning! This is a slow access. Iterator should be used for consecutive parsing.
@@ -139,7 +139,7 @@ public:
   ~NCollection_UtfString();
 
   //! Compares this string with another one.
-  bool IsEqual(const NCollection_UtfString& theCompare) const;
+  bool IsEqual(const NCollection_UtfString& theCompare) const noexcept;
 
   //! Returns the substring.
   //! @param theStart start index (inclusive) of subString
@@ -151,7 +151,7 @@ public:
   //! Returns NULL-terminated Unicode string.
   //! Should not be modified or deleted!
   //! @return (const Type* ) pointer to string
-  const Type* ToCString() const { return myString; }
+  const Type* ToCString() const noexcept { return myString; }
 
   //! @return copy in UTF-8 format
   const NCollection_UtfString<Standard_Utf8Char> ToUtf8() const;
@@ -172,7 +172,7 @@ public:
   bool ToLocale(char* theBuffer, const Standard_Integer theSizeBytes) const;
 
   //! @return true if string is empty
-  bool IsEmpty() const { return myString[0] == Type(0); }
+  bool IsEmpty() const noexcept { return myString[0] == Type(0); }
 
   //! Zero string.
   void Clear();
@@ -182,7 +182,7 @@ public: //! @name assign operators
   const NCollection_UtfString& Assign(const NCollection_UtfString& theOther);
 
   //! Exchange the data of two strings (without reallocating memory).
-  void Swap(NCollection_UtfString& theOther);
+  void Swap(NCollection_UtfString& theOther) noexcept;
 
   //! Copy from another string.
   const NCollection_UtfString& operator=(const NCollection_UtfString& theOther)
@@ -225,9 +225,12 @@ public: //! @name assign operators
   }
 
 public: //! @name compare operators
-  bool operator==(const NCollection_UtfString& theCompare) const { return IsEqual(theCompare); }
+  bool operator==(const NCollection_UtfString& theCompare) const noexcept
+  {
+    return IsEqual(theCompare);
+  }
 
-  bool operator!=(const NCollection_UtfString& theCompare) const;
+  bool operator!=(const NCollection_UtfString& theCompare) const noexcept;
 
 private: //! @name low-level methods
   //! Implementation of copy routine for string of the same type
@@ -301,7 +304,7 @@ private: //! @name low-level methods
   //! Provides bytes interface to avoid incorrect pointer arithmetics.
   static void strCopy(Standard_Byte*         theStrDst,
                       const Standard_Byte*   theStrSrc,
-                      const Standard_Integer theSizeBytes)
+                      const Standard_Integer theSizeBytes) noexcept
   {
     std::memcpy(theStrDst, theStrSrc, (Standard_Size)theSizeBytes);
   }
@@ -310,7 +313,7 @@ private: //! @name low-level methods
   static bool strAreEqual(const Type*            theString1,
                           const Standard_Integer theSizeBytes1,
                           const Type*            theString2,
-                          const Standard_Integer theSizeBytes2)
+                          const Standard_Integer theSizeBytes2) noexcept
   {
     return (theSizeBytes1 == theSizeBytes2)
            && (std::memcmp(theString1, theString2, (Standard_Size)theSizeBytes1) == 0);
index 4c0b0f4a494c36a7fde7a59a96e42b233008d7d7..dd79f149ef4d8b005411573f22d132fd93d5e2cd 100755 (executable)
@@ -176,7 +176,7 @@ inline const NCollection_UtfString<Type>& NCollection_UtfString<Type>::Assign(
 //=================================================================================================
 
 template <typename Type>
-inline void NCollection_UtfString<Type>::Swap(NCollection_UtfString<Type>& theOther)
+inline void NCollection_UtfString<Type>::Swap(NCollection_UtfString<Type>& theOther) noexcept
 {
   // Note: we could use std::swap() here, but prefer to not
   // have dependency on <algorithm> header at that level
@@ -289,7 +289,8 @@ inline const NCollection_UtfString<Type>& NCollection_UtfString<Type>::operator=
 //=================================================================================================
 
 template <typename Type>
-inline bool NCollection_UtfString<Type>::IsEqual(const NCollection_UtfString& theCompare) const
+inline bool NCollection_UtfString<Type>::IsEqual(
+  const NCollection_UtfString& theCompare) const noexcept
 {
   return this == &theCompare
          || strAreEqual(myString, mySize, theCompare.myString, theCompare.mySize);
@@ -300,7 +301,8 @@ inline bool NCollection_UtfString<Type>::IsEqual(const NCollection_UtfString& th
 // purpose  :
 // =======================================================================
 template <typename Type>
-inline bool NCollection_UtfString<Type>::operator!=(const NCollection_UtfString& theCompare) const
+inline bool NCollection_UtfString<Type>::operator!=(
+  const NCollection_UtfString& theCompare) const noexcept
 {
   return (!NCollection_UtfString::operator==(theCompare));
 }
index 0318ed247f4600891ec16745ef6c1193f0ece3a6..f9120f311d1fc74229a1a23663bed3b92cc63948 100644 (file)
 //! Auxiliary macros to define couple of similar access components as vector methods.
 //! @return 2 components by their names in specified order
 #define NCOLLECTION_VEC_COMPONENTS_2D(theX, theY)                                                  \
-  const NCollection_Vec2<Element_t> theX##theY() const                                             \
+  constexpr NCollection_Vec2<Element_t> theX##theY() const noexcept                                \
   {                                                                                                \
     return NCollection_Vec2<Element_t>(theX(), theY());                                            \
   }                                                                                                \
-  const NCollection_Vec2<Element_t> theY##theX() const                                             \
+  constexpr NCollection_Vec2<Element_t> theY##theX() const noexcept                                \
   {                                                                                                \
     return NCollection_Vec2<Element_t>(theY(), theX());                                            \
   }
@@ -39,16 +39,16 @@ class NCollection_Vec2
 
 public:
   //! Returns the number of components.
-  static int Length() { return 2; }
+  static constexpr int Length() noexcept { return 2; }
 
   //! Empty constructor. Construct the zero vector.
-  NCollection_Vec2() { v[0] = v[1] = Element_t(0); }
+  constexpr NCollection_Vec2() noexcept { v[0] = v[1] = Element_t(0); }
 
   //! Initialize ALL components of vector within specified value.
-  explicit NCollection_Vec2(const Element_t theXY) { v[0] = v[1] = theXY; }
+  explicit constexpr NCollection_Vec2(const Element_t theXY) noexcept { v[0] = v[1] = theXY; }
 
   //! Per-component constructor.
-  explicit NCollection_Vec2(const Element_t theX, const Element_t theY)
+  explicit constexpr NCollection_Vec2(const Element_t theX, const Element_t theY) noexcept
   {
     v[0] = theX;
     v[1] = theY;
@@ -60,57 +60,63 @@ public:
   //! @tparam OtherElement_t the element type of the other 2-component vector theOtherVec2
   //! @param theOtherVec2 the 2-component vector that needs to be converted
   template <typename OtherElement_t>
-  explicit NCollection_Vec2(const NCollection_Vec2<OtherElement_t>& theOtherVec2)
+  explicit constexpr NCollection_Vec2(const NCollection_Vec2<OtherElement_t>& theOtherVec2) noexcept
   {
     v[0] = static_cast<Element_t>(theOtherVec2[0]);
     v[1] = static_cast<Element_t>(theOtherVec2[1]);
   }
 
   //! Assign new values to the vector.
-  void SetValues(const Element_t theX, const Element_t theY)
+  constexpr void SetValues(const Element_t theX, const Element_t theY) noexcept
   {
     v[0] = theX;
     v[1] = theY;
   }
 
   //! Alias to 1st component as X coordinate in XY.
-  Element_t x() const { return v[0]; }
+  constexpr Element_t x() const noexcept { return v[0]; }
 
   //! Alias to 2nd component as Y coordinate in XY.
-  Element_t y() const { return v[1]; }
+  constexpr Element_t y() const noexcept { return v[1]; }
 
   //! @return 2 components by their names in specified order (in GLSL-style)
   NCOLLECTION_VEC_COMPONENTS_2D(x, y)
 
   //! Alias to 1st component as X coordinate in XY.
-  Element_t& x() { return v[0]; }
+  constexpr Element_t& x() noexcept { return v[0]; }
 
   //! Alias to 2nd component as Y coordinate in XY.
-  Element_t& y() { return v[1]; }
+  constexpr Element_t& y() noexcept { return v[1]; }
 
   //! Check this vector with another vector for equality (without tolerance!).
-  bool IsEqual(const NCollection_Vec2& theOther) const
+  constexpr bool IsEqual(const NCollection_Vec2& theOther) const noexcept
   {
     return v[0] == theOther.v[0] && v[1] == theOther.v[1];
   }
 
   //! Check this vector with another vector for equality (without tolerance!).
-  bool operator==(const NCollection_Vec2& theOther) const { return IsEqual(theOther); }
+  constexpr bool operator==(const NCollection_Vec2& theOther) const noexcept
+  {
+    return IsEqual(theOther);
+  }
 
   //! Check this vector with another vector for non-equality (without tolerance!).
-  bool operator!=(const NCollection_Vec2& theOther) const { return !IsEqual(theOther); }
+  constexpr bool operator!=(const NCollection_Vec2& theOther) const noexcept
+  {
+    return !IsEqual(theOther);
+  }
 
   //! Raw access to the data (for OpenGL exchange).
-  const Element_t* GetData() const { return v; }
+  constexpr const Element_t* GetData() const noexcept { return v; }
 
-  Element_t* ChangeData() { return v; }
+  constexpr Element_t* ChangeData() noexcept { return v; }
 
-  operator const Element_t*() const { return v; }
+  constexpr operator const Element_t*() const noexcept { return v; }
 
-  operator Element_t*() { return v; }
+  constexpr operator Element_t*() noexcept { return v; }
 
   //! Compute per-component summary.
-  NCollection_Vec2& operator+=(const NCollection_Vec2& theAdd)
+  constexpr NCollection_Vec2& operator+=(const NCollection_Vec2& theAdd) noexcept
   {
     v[0] += theAdd.v[0];
     v[1] += theAdd.v[1];
@@ -118,14 +124,14 @@ public:
   }
 
   //! Compute per-component summary.
-  friend NCollection_Vec2 operator+(const NCollection_Vec2& theLeft,
-                                    const NCollection_Vec2& theRight)
+  friend constexpr NCollection_Vec2 operator+(const NCollection_Vec2& theLeft,
+                                              const NCollection_Vec2& theRight) noexcept
   {
     return NCollection_Vec2(theLeft.v[0] + theRight.v[0], theLeft.v[1] + theRight.v[1]);
   }
 
   //! Compute per-component subtraction.
-  NCollection_Vec2& operator-=(const NCollection_Vec2& theDec)
+  constexpr NCollection_Vec2& operator-=(const NCollection_Vec2& theDec) noexcept
   {
     v[0] -= theDec.v[0];
     v[1] -= theDec.v[1];
@@ -133,17 +139,17 @@ public:
   }
 
   //! Compute per-component subtraction.
-  friend NCollection_Vec2 operator-(const NCollection_Vec2& theLeft,
-                                    const NCollection_Vec2& theRight)
+  friend constexpr NCollection_Vec2 operator-(const NCollection_Vec2& theLeft,
+                                              const NCollection_Vec2& theRight) noexcept
   {
     return NCollection_Vec2(theLeft.v[0] - theRight.v[0], theLeft.v[1] - theRight.v[1]);
   }
 
   //! Unary -.
-  NCollection_Vec2 operator-() const { return NCollection_Vec2(-x(), -y()); }
+  constexpr NCollection_Vec2 operator-() const noexcept { return NCollection_Vec2(-x(), -y()); }
 
   //! Compute per-component multiplication.
-  NCollection_Vec2& operator*=(const NCollection_Vec2& theRight)
+  constexpr NCollection_Vec2& operator*=(const NCollection_Vec2& theRight) noexcept
   {
     v[0] *= theRight.v[0];
     v[1] *= theRight.v[1];
@@ -151,57 +157,60 @@ public:
   }
 
   //! Compute per-component multiplication.
-  friend NCollection_Vec2 operator*(const NCollection_Vec2& theLeft,
-                                    const NCollection_Vec2& theRight)
+  friend constexpr NCollection_Vec2 operator*(const NCollection_Vec2& theLeft,
+                                              const NCollection_Vec2& theRight) noexcept
   {
     return NCollection_Vec2(theLeft.v[0] * theRight.v[0], theLeft.v[1] * theRight.v[1]);
   }
 
   //! Compute per-component multiplication by scale factor.
-  void Multiply(const Element_t theFactor)
+  constexpr void Multiply(const Element_t theFactor) noexcept
   {
     v[0] *= theFactor;
     v[1] *= theFactor;
   }
 
   //! Compute per-component multiplication by scale factor.
-  NCollection_Vec2 Multiplied(const Element_t theFactor) const
+  constexpr NCollection_Vec2 Multiplied(const Element_t theFactor) const noexcept
   {
     return NCollection_Vec2(v[0] * theFactor, v[1] * theFactor);
   }
 
   //! Compute component-wise minimum of two vectors.
-  NCollection_Vec2 cwiseMin(const NCollection_Vec2& theVec) const
+  constexpr NCollection_Vec2 cwiseMin(const NCollection_Vec2& theVec) const noexcept
   {
     return NCollection_Vec2(v[0] < theVec.v[0] ? v[0] : theVec.v[0],
                             v[1] < theVec.v[1] ? v[1] : theVec.v[1]);
   }
 
   //! Compute component-wise maximum of two vectors.
-  NCollection_Vec2 cwiseMax(const NCollection_Vec2& theVec) const
+  constexpr NCollection_Vec2 cwiseMax(const NCollection_Vec2& theVec) const noexcept
   {
     return NCollection_Vec2(v[0] > theVec.v[0] ? v[0] : theVec.v[0],
                             v[1] > theVec.v[1] ? v[1] : theVec.v[1]);
   }
 
   //! Compute component-wise modulus of the vector.
-  NCollection_Vec2 cwiseAbs() const { return NCollection_Vec2(std::abs(v[0]), std::abs(v[1])); }
+  NCollection_Vec2 cwiseAbs() const noexcept
+  {
+    return NCollection_Vec2(std::abs(v[0]), std::abs(v[1]));
+  }
 
   //! Compute maximum component of the vector.
-  Element_t maxComp() const { return v[0] > v[1] ? v[0] : v[1]; }
+  constexpr Element_t maxComp() const noexcept { return v[0] > v[1] ? v[0] : v[1]; }
 
   //! Compute minimum component of the vector.
-  Element_t minComp() const { return v[0] < v[1] ? v[0] : v[1]; }
+  constexpr Element_t minComp() const noexcept { return v[0] < v[1] ? v[0] : v[1]; }
 
   //! Compute per-component multiplication by scale factor.
-  NCollection_Vec2& operator*=(const Element_t theFactor)
+  constexpr NCollection_Vec2& operator*=(const Element_t theFactor) noexcept
   {
     Multiply(theFactor);
     return *this;
   }
 
   //! Compute per-component division by scale factor.
-  NCollection_Vec2& operator/=(const Element_t theInvFactor)
+  constexpr NCollection_Vec2& operator/=(const Element_t theInvFactor)
   {
     v[0] /= theInvFactor;
     v[1] /= theInvFactor;
@@ -209,7 +218,7 @@ public:
   }
 
   //! Compute per-component division.
-  NCollection_Vec2& operator/=(const NCollection_Vec2& theRight)
+  constexpr NCollection_Vec2& operator/=(const NCollection_Vec2& theRight)
   {
     v[0] /= theRight.v[0];
     v[1] /= theRight.v[1];
@@ -217,39 +226,48 @@ public:
   }
 
   //! Compute per-component multiplication by scale factor.
-  NCollection_Vec2 operator*(const Element_t theFactor) const { return Multiplied(theFactor); }
+  constexpr NCollection_Vec2 operator*(const Element_t theFactor) const noexcept
+  {
+    return Multiplied(theFactor);
+  }
 
   //! Compute per-component division by scale factor.
-  NCollection_Vec2 operator/(const Element_t theInvFactor) const
+  constexpr NCollection_Vec2 operator/(const Element_t theInvFactor) const
   {
     return NCollection_Vec2(v[0] / theInvFactor, v[1] / theInvFactor);
   }
 
   //! Compute per-component division.
-  friend NCollection_Vec2 operator/(const NCollection_Vec2& theLeft,
-                                    const NCollection_Vec2& theRight)
+  friend constexpr NCollection_Vec2 operator/(const NCollection_Vec2& theLeft,
+                                              const NCollection_Vec2& theRight)
   {
     return NCollection_Vec2(theLeft.v[0] / theRight.v[0], theLeft.v[1] / theRight.v[1]);
   }
 
   //! Computes the dot product.
-  Element_t Dot(const NCollection_Vec2& theOther) const
+  constexpr Element_t Dot(const NCollection_Vec2& theOther) const noexcept
   {
     return x() * theOther.x() + y() * theOther.y();
   }
 
   //! Computes the vector modulus (magnitude, length).
-  Element_t Modulus() const { return std::sqrt(x() * x() + y() * y()); }
+  Element_t Modulus() const noexcept { return std::sqrt(x() * x() + y() * y()); }
 
   //! Computes the square of vector modulus (magnitude, length).
   //! This method may be used for performance tricks.
-  Element_t SquareModulus() const { return x() * x() + y() * y(); }
+  constexpr Element_t SquareModulus() const noexcept { return x() * x() + y() * y(); }
 
   //! Construct DX unit vector.
-  static NCollection_Vec2 DX() { return NCollection_Vec2(Element_t(1), Element_t(0)); }
+  static constexpr NCollection_Vec2 DX() noexcept
+  {
+    return NCollection_Vec2(Element_t(1), Element_t(0));
+  }
 
   //! Construct DY unit vector.
-  static NCollection_Vec2 DY() { return NCollection_Vec2(Element_t(0), Element_t(1)); }
+  static constexpr NCollection_Vec2 DY() noexcept
+  {
+    return NCollection_Vec2(Element_t(0), Element_t(1));
+  }
 
   //! Dumps the content of me into the stream
   void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const
index 25aba17c0ee18054643343854baa64591ff8738e..82507e29e26f5f9e8c2a087da2ead4b2fdfcc27b 100644 (file)
 
 //! Auxiliary macros to define couple of similar access components as vector methods
 #define NCOLLECTION_VEC_COMPONENTS_3D(theX, theY, theZ)                                            \
-  const NCollection_Vec3<Element_t> theX##theY##theZ() const                                       \
+  constexpr NCollection_Vec3<Element_t> theX##theY##theZ() const noexcept                          \
   {                                                                                                \
     return NCollection_Vec3<Element_t>(theX(), theY(), theZ());                                    \
   }                                                                                                \
-  const NCollection_Vec3<Element_t> theX##theZ##theY() const                                       \
+  constexpr NCollection_Vec3<Element_t> theX##theZ##theY() const noexcept                          \
   {                                                                                                \
     return NCollection_Vec3<Element_t>(theX(), theZ(), theY());                                    \
   }                                                                                                \
-  const NCollection_Vec3<Element_t> theY##theX##theZ() const                                       \
+  constexpr NCollection_Vec3<Element_t> theY##theX##theZ() const noexcept                          \
   {                                                                                                \
     return NCollection_Vec3<Element_t>(theY(), theX(), theZ());                                    \
   }                                                                                                \
-  const NCollection_Vec3<Element_t> theY##theZ##theX() const                                       \
+  constexpr NCollection_Vec3<Element_t> theY##theZ##theX() const noexcept                          \
   {                                                                                                \
     return NCollection_Vec3<Element_t>(theY(), theZ(), theX());                                    \
   }                                                                                                \
-  const NCollection_Vec3<Element_t> theZ##theY##theX() const                                       \
+  constexpr NCollection_Vec3<Element_t> theZ##theY##theX() const noexcept                          \
   {                                                                                                \
     return NCollection_Vec3<Element_t>(theZ(), theY(), theX());                                    \
   }                                                                                                \
-  const NCollection_Vec3<Element_t> theZ##theX##theY() const                                       \
+  constexpr NCollection_Vec3<Element_t> theZ##theX##theY() const noexcept                          \
   {                                                                                                \
     return NCollection_Vec3<Element_t>(theZ(), theX(), theY());                                    \
   }
@@ -55,16 +55,21 @@ class NCollection_Vec3
 
 public:
   //! Returns the number of components.
-  static int Length() { return 3; }
+  static constexpr int Length() noexcept { return 3; }
 
   //! Empty constructor. Construct the zero vector.
   NCollection_Vec3() { std::memset(this, 0, sizeof(NCollection_Vec3)); }
 
   //! Initialize ALL components of vector within specified value.
-  explicit NCollection_Vec3(Element_t theValue) { v[0] = v[1] = v[2] = theValue; }
+  explicit constexpr NCollection_Vec3(Element_t theValue) noexcept
+  {
+    v[0] = v[1] = v[2] = theValue;
+  }
 
   //! Per-component constructor.
-  explicit NCollection_Vec3(const Element_t theX, const Element_t theY, const Element_t theZ)
+  explicit constexpr NCollection_Vec3(const Element_t theX,
+                                      const Element_t theY,
+                                      const Element_t theZ) noexcept
   {
     v[0] = theX;
     v[1] = theY;
@@ -72,8 +77,8 @@ public:
   }
 
   //! Constructor from 2-components vector + optional 3rd value.
-  explicit NCollection_Vec3(const NCollection_Vec2<Element_t>& theVec2,
-                            Element_t                          theZ = Element_t(0))
+  explicit constexpr NCollection_Vec3(const NCollection_Vec2<Element_t>& theVec2,
+                                      Element_t theZ = Element_t(0)) noexcept
   {
     v[0] = theVec2[0];
     v[1] = theVec2[1];
@@ -86,7 +91,7 @@ public:
   //! @tparam OtherElement_t the element type of the other 3-component vector theOtherVec3
   //! @param theOtherVec3 the 3-component vector that needs to be converted
   template <typename OtherElement_t>
-  explicit NCollection_Vec3(const NCollection_Vec3<OtherElement_t>& theOtherVec3)
+  explicit constexpr NCollection_Vec3(const NCollection_Vec3<OtherElement_t>& theOtherVec3) noexcept
   {
     v[0] = static_cast<Element_t>(theOtherVec3[0]);
     v[1] = static_cast<Element_t>(theOtherVec3[1]);
@@ -94,7 +99,9 @@ public:
   }
 
   //! Assign new values to the vector.
-  void SetValues(const Element_t theX, const Element_t theY, const Element_t theZ)
+  constexpr void SetValues(const Element_t theX,
+                           const Element_t theY,
+                           const Element_t theZ) noexcept
   {
     v[0] = theX;
     v[1] = theY;
@@ -102,7 +109,7 @@ public:
   }
 
   //! Assign new values to the vector.
-  void SetValues(const NCollection_Vec2<Element_t>& theVec2, Element_t theZ)
+  constexpr void SetValues(const NCollection_Vec2<Element_t>& theVec2, Element_t theZ) noexcept
   {
     v[0] = theVec2.x();
     v[1] = theVec2.y();
@@ -110,22 +117,22 @@ public:
   }
 
   //! Alias to 1st component as X coordinate in XYZ.
-  Element_t x() const { return v[0]; }
+  constexpr Element_t x() const noexcept { return v[0]; }
 
   //! Alias to 1st component as RED channel in RGB.
-  Element_t r() const { return v[0]; }
+  constexpr Element_t r() const noexcept { return v[0]; }
 
   //! Alias to 2nd component as Y coordinate in XYZ.
-  Element_t y() const { return v[1]; }
+  constexpr Element_t y() const noexcept { return v[1]; }
 
   //! Alias to 2nd component as GREEN channel in RGB.
-  Element_t g() const { return v[1]; }
+  constexpr Element_t g() const noexcept { return v[1]; }
 
   //! Alias to 3rd component as Z coordinate in XYZ.
-  Element_t z() const { return v[2]; }
+  constexpr Element_t z() const noexcept { return v[2]; }
 
   //! Alias to 3rd component as BLUE channel in RGB.
-  Element_t b() const { return v[2]; }
+  constexpr Element_t b() const noexcept { return v[2]; }
 
   //! @return 2 components by their names in specified order (in GLSL-style)
   NCOLLECTION_VEC_COMPONENTS_2D(x, y)
@@ -136,46 +143,52 @@ public:
   NCOLLECTION_VEC_COMPONENTS_3D(x, y, z)
 
   //! Alias to 1st component as X coordinate in XYZ.
-  Element_t& x() { return v[0]; }
+  constexpr Element_t& x() noexcept { return v[0]; }
 
   //! Alias to 1st component as RED channel in RGB.
-  Element_t& r() { return v[0]; }
+  constexpr Element_t& r() noexcept { return v[0]; }
 
   //! Alias to 2nd component as Y coordinate in XYZ.
-  Element_t& y() { return v[1]; }
+  constexpr Element_t& y() noexcept { return v[1]; }
 
   //! Alias to 2nd component as GREEN channel in RGB.
-  Element_t& g() { return v[1]; }
+  constexpr Element_t& g() noexcept { return v[1]; }
 
   //! Alias to 3rd component as Z coordinate in XYZ.
-  Element_t& z() { return v[2]; }
+  constexpr Element_t& z() noexcept { return v[2]; }
 
   //! Alias to 3rd component as BLUE channel in RGB.
-  Element_t& b() { return v[2]; }
+  constexpr Element_t& b() noexcept { return v[2]; }
 
   //! Check this vector with another vector for equality (without tolerance!).
-  bool IsEqual(const NCollection_Vec3& theOther) const
+  constexpr bool IsEqual(const NCollection_Vec3& theOther) const noexcept
   {
     return v[0] == theOther.v[0] && v[1] == theOther.v[1] && v[2] == theOther.v[2];
   }
 
   //! Check this vector with another vector for equality (without tolerance!).
-  bool operator==(const NCollection_Vec3& theOther) const { return IsEqual(theOther); }
+  constexpr bool operator==(const NCollection_Vec3& theOther) const noexcept
+  {
+    return IsEqual(theOther);
+  }
 
   //! Check this vector with another vector for non-equality (without tolerance!).
-  bool operator!=(const NCollection_Vec3& theOther) const { return !IsEqual(theOther); }
+  constexpr bool operator!=(const NCollection_Vec3& theOther) const noexcept
+  {
+    return !IsEqual(theOther);
+  }
 
   //! Raw access to the data (for OpenGL exchange).
-  const Element_t* GetData() const { return v; }
+  constexpr const Element_t* GetData() const noexcept { return v; }
 
-  Element_t* ChangeData() { return v; }
+  constexpr Element_t* ChangeData() noexcept { return v; }
 
-  operator const Element_t*() const { return v; }
+  constexpr operator const Element_t*() const noexcept { return v; }
 
-  operator Element_t*() { return v; }
+  constexpr operator Element_t*() noexcept { return v; }
 
   //! Compute per-component summary.
-  NCollection_Vec3& operator+=(const NCollection_Vec3& theAdd)
+  constexpr NCollection_Vec3& operator+=(const NCollection_Vec3& theAdd) noexcept
   {
     v[0] += theAdd.v[0];
     v[1] += theAdd.v[1];
@@ -184,18 +197,21 @@ public:
   }
 
   //! Compute per-component summary.
-  friend NCollection_Vec3 operator+(const NCollection_Vec3& theLeft,
-                                    const NCollection_Vec3& theRight)
+  friend constexpr NCollection_Vec3 operator+(const NCollection_Vec3& theLeft,
+                                              const NCollection_Vec3& theRight) noexcept
   {
     NCollection_Vec3 aSumm = NCollection_Vec3(theLeft);
     return aSumm += theRight;
   }
 
   //! Unary -.
-  NCollection_Vec3 operator-() const { return NCollection_Vec3(-x(), -y(), -z()); }
+  constexpr NCollection_Vec3 operator-() const noexcept
+  {
+    return NCollection_Vec3(-x(), -y(), -z());
+  }
 
   //! Compute per-component subtraction.
-  NCollection_Vec3& operator-=(const NCollection_Vec3& theDec)
+  constexpr NCollection_Vec3& operator-=(const NCollection_Vec3& theDec) noexcept
   {
     v[0] -= theDec.v[0];
     v[1] -= theDec.v[1];
@@ -204,15 +220,15 @@ public:
   }
 
   //! Compute per-component subtraction.
-  friend NCollection_Vec3 operator-(const NCollection_Vec3& theLeft,
-                                    const NCollection_Vec3& theRight)
+  friend constexpr NCollection_Vec3 operator-(const NCollection_Vec3& theLeft,
+                                              const NCollection_Vec3& theRight) noexcept
   {
     NCollection_Vec3 aSumm = NCollection_Vec3(theLeft);
     return aSumm -= theRight;
   }
 
   //! Compute per-component multiplication by scale factor.
-  void Multiply(const Element_t theFactor)
+  constexpr void Multiply(const Element_t theFactor) noexcept
   {
     v[0] *= theFactor;
     v[1] *= theFactor;
@@ -220,7 +236,7 @@ public:
   }
 
   //! Compute per-component multiplication.
-  NCollection_Vec3& operator*=(const NCollection_Vec3& theRight)
+  constexpr NCollection_Vec3& operator*=(const NCollection_Vec3& theRight) noexcept
   {
     v[0] *= theRight.v[0];
     v[1] *= theRight.v[1];
@@ -229,25 +245,28 @@ public:
   }
 
   //! Compute per-component multiplication.
-  friend NCollection_Vec3 operator*(const NCollection_Vec3& theLeft,
-                                    const NCollection_Vec3& theRight)
+  friend constexpr NCollection_Vec3 operator*(const NCollection_Vec3& theLeft,
+                                              const NCollection_Vec3& theRight) noexcept
   {
     NCollection_Vec3 aResult = NCollection_Vec3(theLeft);
     return aResult *= theRight;
   }
 
   //! Compute per-component multiplication by scale factor.
-  NCollection_Vec3& operator*=(const Element_t theFactor)
+  constexpr NCollection_Vec3& operator*=(const Element_t theFactor) noexcept
   {
     Multiply(theFactor);
     return *this;
   }
 
   //! Compute per-component multiplication by scale factor.
-  NCollection_Vec3 operator*(const Element_t theFactor) const { return Multiplied(theFactor); }
+  constexpr NCollection_Vec3 operator*(const Element_t theFactor) const noexcept
+  {
+    return Multiplied(theFactor);
+  }
 
   //! Compute per-component multiplication by scale factor.
-  NCollection_Vec3 Multiplied(const Element_t theFactor) const
+  constexpr NCollection_Vec3 Multiplied(const Element_t theFactor) const noexcept
   {
     NCollection_Vec3 aCopyVec3(*this);
     aCopyVec3 *= theFactor;
@@ -255,7 +274,7 @@ public:
   }
 
   //! Compute component-wise minimum of two vectors.
-  NCollection_Vec3 cwiseMin(const NCollection_Vec3& theVec) const
+  constexpr NCollection_Vec3 cwiseMin(const NCollection_Vec3& theVec) const noexcept
   {
     return NCollection_Vec3(v[0] < theVec.v[0] ? v[0] : theVec.v[0],
                             v[1] < theVec.v[1] ? v[1] : theVec.v[1],
@@ -263,7 +282,7 @@ public:
   }
 
   //! Compute component-wise maximum of two vectors.
-  NCollection_Vec3 cwiseMax(const NCollection_Vec3& theVec) const
+  constexpr NCollection_Vec3 cwiseMax(const NCollection_Vec3& theVec) const noexcept
   {
     return NCollection_Vec3(v[0] > theVec.v[0] ? v[0] : theVec.v[0],
                             v[1] > theVec.v[1] ? v[1] : theVec.v[1],
@@ -271,25 +290,25 @@ public:
   }
 
   //! Compute component-wise modulus of the vector.
-  NCollection_Vec3 cwiseAbs() const
+  NCollection_Vec3 cwiseAbs() const noexcept
   {
     return NCollection_Vec3(std::abs(v[0]), std::abs(v[1]), std::abs(v[2]));
   }
 
   //! Compute maximum component of the vector.
-  Element_t maxComp() const
+  constexpr Element_t maxComp() const noexcept
   {
     return v[0] > v[1] ? (v[0] > v[2] ? v[0] : v[2]) : (v[1] > v[2] ? v[1] : v[2]);
   }
 
   //! Compute minimum component of the vector.
-  Element_t minComp() const
+  constexpr Element_t minComp() const noexcept
   {
     return v[0] < v[1] ? (v[0] < v[2] ? v[0] : v[2]) : (v[1] < v[2] ? v[1] : v[2]);
   }
 
   //! Compute per-component division by scale factor.
-  NCollection_Vec3& operator/=(const Element_t theInvFactor)
+  constexpr NCollection_Vec3& operator/=(const Element_t theInvFactor)
   {
     v[0] /= theInvFactor;
     v[1] /= theInvFactor;
@@ -298,7 +317,7 @@ public:
   }
 
   //! Compute per-component division.
-  NCollection_Vec3& operator/=(const NCollection_Vec3& theRight)
+  constexpr NCollection_Vec3& operator/=(const NCollection_Vec3& theRight)
   {
     v[0] /= theRight.v[0];
     v[1] /= theRight.v[1];
@@ -307,32 +326,32 @@ public:
   }
 
   //! Compute per-component division by scale factor.
-  NCollection_Vec3 operator/(const Element_t theInvFactor) const
+  constexpr NCollection_Vec3 operator/(const Element_t theInvFactor) const
   {
     NCollection_Vec3 aResult(*this);
     return aResult /= theInvFactor;
   }
 
   //! Compute per-component division.
-  friend NCollection_Vec3 operator/(const NCollection_Vec3& theLeft,
-                                    const NCollection_Vec3& theRight)
+  friend constexpr NCollection_Vec3 operator/(const NCollection_Vec3& theLeft,
+                                              const NCollection_Vec3& theRight)
   {
     NCollection_Vec3 aResult = NCollection_Vec3(theLeft);
     return aResult /= theRight;
   }
 
   //! Computes the dot product.
-  Element_t Dot(const NCollection_Vec3& theOther) const
+  constexpr Element_t Dot(const NCollection_Vec3& theOther) const noexcept
   {
     return x() * theOther.x() + y() * theOther.y() + z() * theOther.z();
   }
 
   //! Computes the vector modulus (magnitude, length).
-  Element_t Modulus() const { return std::sqrt(x() * x() + y() * y() + z() * z()); }
+  Element_t Modulus() const noexcept { return std::sqrt(x() * x() + y() * y() + z() * z()); }
 
   //! Computes the square of vector modulus (magnitude, length).
   //! This method may be used for performance tricks.
-  Element_t SquareModulus() const { return x() * x() + y() * y() + z() * z(); }
+  constexpr Element_t SquareModulus() const noexcept { return x() * x() + y() * y() + z() * z(); }
 
   //! Normalize the vector.
   void Normalize()
@@ -355,7 +374,8 @@ public:
   }
 
   //! Computes the cross product.
-  static NCollection_Vec3 Cross(const NCollection_Vec3& theVec1, const NCollection_Vec3& theVec2)
+  static constexpr NCollection_Vec3 Cross(const NCollection_Vec3& theVec1,
+                                          const NCollection_Vec3& theVec2) noexcept
   {
     return NCollection_Vec3(theVec1.y() * theVec2.z() - theVec1.z() * theVec2.y(),
                             theVec1.z() * theVec2.x() - theVec1.x() * theVec2.z(),
@@ -365,27 +385,27 @@ public:
   //! Compute linear interpolation between to vectors.
   //! @param theT - interpolation coefficient 0..1;
   //! @return interpolation result.
-  static NCollection_Vec3 GetLERP(const NCollection_Vec3& theFrom,
-                                  const NCollection_Vec3& theTo,
-                                  const Element_t         theT)
+  static constexpr NCollection_Vec3 GetLERP(const NCollection_Vec3& theFrom,
+                                            const NCollection_Vec3& theTo,
+                                            const Element_t         theT) noexcept
   {
     return theFrom * (Element_t(1) - theT) + theTo * theT;
   }
 
   //! Construct DX unit vector.
-  static NCollection_Vec3 DX()
+  static constexpr NCollection_Vec3 DX() noexcept
   {
     return NCollection_Vec3(Element_t(1), Element_t(0), Element_t(0));
   }
 
   //! Construct DY unit vector.
-  static NCollection_Vec3 DY()
+  static constexpr NCollection_Vec3 DY() noexcept
   {
     return NCollection_Vec3(Element_t(0), Element_t(1), Element_t(0));
   }
 
   //! Construct DZ unit vector.
-  static NCollection_Vec3 DZ()
+  static constexpr NCollection_Vec3 DZ() noexcept
   {
     return NCollection_Vec3(Element_t(0), Element_t(0), Element_t(1));
   }
@@ -403,7 +423,8 @@ private:
 
 //! Optimized concretization for float type.
 template <>
-inline NCollection_Vec3<float>& NCollection_Vec3<float>::operator/=(const float theInvFactor)
+inline constexpr NCollection_Vec3<float>& NCollection_Vec3<float>::operator/=(
+  const float theInvFactor)
 {
   Multiply(1.0f / theInvFactor);
   return *this;
@@ -411,7 +432,8 @@ inline NCollection_Vec3<float>& NCollection_Vec3<float>::operator/=(const float
 
 //! Optimized concretization for double type.
 template <>
-inline NCollection_Vec3<double>& NCollection_Vec3<double>::operator/=(const double theInvFactor)
+inline constexpr NCollection_Vec3<double>& NCollection_Vec3<double>::operator/=(
+  const double theInvFactor)
 {
   Multiply(1.0 / theInvFactor);
   return *this;
index e2cd23e36d5c7c3bdb2bae7289bc899c4931845c..48f300c004435f549f634c731ee77ef78a595951 100644 (file)
@@ -28,19 +28,22 @@ class NCollection_Vec4
 
 public:
   //! Returns the number of components.
-  static int Length() { return 4; }
+  static constexpr int Length() noexcept { return 4; }
 
   //! Empty constructor. Construct the zero vector.
   NCollection_Vec4() { std::memset(this, 0, sizeof(NCollection_Vec4)); }
 
   //! Initialize ALL components of vector within specified value.
-  explicit NCollection_Vec4(const Element_t theValue) { v[0] = v[1] = v[2] = v[3] = theValue; }
+  explicit constexpr NCollection_Vec4(const Element_t theValue) noexcept
+  {
+    v[0] = v[1] = v[2] = v[3] = theValue;
+  }
 
   //! Per-component constructor.
-  explicit NCollection_Vec4(const Element_t theX,
-                            const Element_t theY,
-                            const Element_t theZ,
-                            const Element_t theW)
+  explicit constexpr NCollection_Vec4(const Element_t theX,
+                                      const Element_t theY,
+                                      const Element_t theZ,
+                                      const Element_t theW) noexcept
   {
     v[0] = theX;
     v[1] = theY;
@@ -49,7 +52,7 @@ public:
   }
 
   //! Constructor from 2-components vector.
-  explicit NCollection_Vec4(const NCollection_Vec2<Element_t>& theVec2)
+  explicit constexpr NCollection_Vec4(const NCollection_Vec2<Element_t>& theVec2) noexcept
   {
     v[0] = theVec2[0];
     v[1] = theVec2[1];
@@ -70,7 +73,7 @@ public:
   //! @tparam OtherElement_t the element type of the other 4-component vector theOtherVec4
   //! @param theOtherVec4 the 4-component vector that needs to be converted
   template <typename OtherElement_t>
-  explicit NCollection_Vec4(const NCollection_Vec4<OtherElement_t>& theOtherVec4)
+  explicit constexpr NCollection_Vec4(const NCollection_Vec4<OtherElement_t>& theOtherVec4) noexcept
   {
     v[0] = static_cast<Element_t>(theOtherVec4[0]);
     v[1] = static_cast<Element_t>(theOtherVec4[1]);
@@ -79,10 +82,10 @@ public:
   }
 
   //! Assign new values to the vector.
-  void SetValues(const Element_t theX,
-                 const Element_t theY,
-                 const Element_t theZ,
-                 const Element_t theW)
+  constexpr void SetValues(const Element_t theX,
+                           const Element_t theY,
+                           const Element_t theZ,
+                           const Element_t theW) noexcept
   {
     v[0] = theX;
     v[1] = theY;
@@ -91,7 +94,8 @@ public:
   }
 
   //! Assign new values as 3-component vector and a 4-th value.
-  void SetValues(const NCollection_Vec3<Element_t>& theVec3, const Element_t theW)
+  constexpr void SetValues(const NCollection_Vec3<Element_t>& theVec3,
+                           const Element_t                    theW) noexcept
   {
     v[0] = theVec3.x();
     v[1] = theVec3.y();
@@ -100,28 +104,28 @@ public:
   }
 
   //! Alias to 1st component as X coordinate in XYZW.
-  Element_t x() const { return v[0]; }
+  constexpr Element_t x() const noexcept { return v[0]; }
 
   //! Alias to 1st component as RED channel in RGBA.
-  Element_t r() const { return v[0]; }
+  constexpr Element_t r() const noexcept { return v[0]; }
 
   //! Alias to 2nd component as Y coordinate in XYZW.
-  Element_t y() const { return v[1]; }
+  constexpr Element_t y() const noexcept { return v[1]; }
 
   //! Alias to 2nd component as GREEN channel in RGBA.
-  Element_t g() const { return v[1]; }
+  constexpr Element_t g() const noexcept { return v[1]; }
 
   //! Alias to 3rd component as Z coordinate in XYZW.
-  Element_t z() const { return v[2]; }
+  constexpr Element_t z() const noexcept { return v[2]; }
 
   //! Alias to 3rd component as BLUE channel in RGBA.
-  Element_t b() const { return v[2]; }
+  constexpr Element_t b() const noexcept { return v[2]; }
 
   //! Alias to 4th component as W coordinate in XYZW.
-  Element_t w() const { return v[3]; }
+  constexpr Element_t w() const noexcept { return v[3]; }
 
   //! Alias to 4th component as ALPHA channel in RGBA.
-  Element_t a() const { return v[3]; }
+  constexpr Element_t a() const noexcept { return v[3]; }
 
   //! @return 2 of XYZW components in specified order as vector in GLSL-style
   NCOLLECTION_VEC_COMPONENTS_2D(x, y)
@@ -141,53 +145,59 @@ public:
   NCOLLECTION_VEC_COMPONENTS_3D(r, g, b)
 
   //! Alias to 1st component as X coordinate in XYZW.
-  Element_t& x() { return v[0]; }
+  constexpr Element_t& x() noexcept { return v[0]; }
 
   //! Alias to 1st component as RED channel in RGBA.
-  Element_t& r() { return v[0]; }
+  constexpr Element_t& r() noexcept { return v[0]; }
 
   //! Alias to 2nd component as Y coordinate in XYZW.
-  Element_t& y() { return v[1]; }
+  constexpr Element_t& y() noexcept { return v[1]; }
 
   //! Alias to 2nd component as GREEN channel in RGBA.
-  Element_t& g() { return v[1]; } // Green color
+  constexpr Element_t& g() noexcept { return v[1]; } // Green color
 
   //! Alias to 3rd component as Z coordinate in XYZW.
-  Element_t& z() { return v[2]; }
+  constexpr Element_t& z() noexcept { return v[2]; }
 
   //! Alias to 3rd component as BLUE channel in RGBA.
-  Element_t& b() { return v[2]; }
+  constexpr Element_t& b() noexcept { return v[2]; }
 
   //! Alias to 4th component as W coordinate in XYZW.
-  Element_t& w() { return v[3]; }
+  constexpr Element_t& w() noexcept { return v[3]; }
 
   //! Alias to 4th component as ALPHA channel in RGBA.
-  Element_t& a() { return v[3]; }
+  constexpr Element_t& a() noexcept { return v[3]; }
 
   //! Check this vector with another vector for equality (without tolerance!).
-  bool IsEqual(const NCollection_Vec4& theOther) const
+  constexpr bool IsEqual(const NCollection_Vec4& theOther) const noexcept
   {
     return v[0] == theOther.v[0] && v[1] == theOther.v[1] && v[2] == theOther.v[2]
            && v[3] == theOther.v[3];
   }
 
   //! Check this vector with another vector for equality (without tolerance!).
-  bool operator==(const NCollection_Vec4& theOther) const { return IsEqual(theOther); }
+  constexpr bool operator==(const NCollection_Vec4& theOther) const noexcept
+  {
+    return IsEqual(theOther);
+  }
 
   //! Check this vector with another vector for non-equality (without tolerance!).
-  bool operator!=(const NCollection_Vec4& theOther) const { return !IsEqual(theOther); }
+  constexpr bool operator!=(const NCollection_Vec4& theOther) const noexcept
+  {
+    return !IsEqual(theOther);
+  }
 
   //! Raw access to the data (for OpenGL exchange).
-  const Element_t* GetData() const { return v; }
+  constexpr const Element_t* GetData() const noexcept { return v; }
 
-  Element_t* ChangeData() { return v; }
+  constexpr Element_t* ChangeData() noexcept { return v; }
 
-  operator const Element_t*() const { return v; }
+  constexpr operator const Element_t*() const noexcept { return v; }
 
-  operator Element_t*() { return v; }
+  constexpr operator Element_t*() noexcept { return v; }
 
   //! Compute per-component summary.
-  NCollection_Vec4& operator+=(const NCollection_Vec4& theAdd)
+  constexpr NCollection_Vec4& operator+=(const NCollection_Vec4& theAdd) noexcept
   {
     v[0] += theAdd.v[0];
     v[1] += theAdd.v[1];
@@ -197,18 +207,21 @@ public:
   }
 
   //! Compute per-component summary.
-  friend NCollection_Vec4 operator+(const NCollection_Vec4& theLeft,
-                                    const NCollection_Vec4& theRight)
+  friend constexpr NCollection_Vec4 operator+(const NCollection_Vec4& theLeft,
+                                              const NCollection_Vec4& theRight) noexcept
   {
     NCollection_Vec4 aSumm = NCollection_Vec4(theLeft);
     return aSumm += theRight;
   }
 
   //! Unary -.
-  NCollection_Vec4 operator-() const { return NCollection_Vec4(-x(), -y(), -z(), -w()); }
+  constexpr NCollection_Vec4 operator-() const noexcept
+  {
+    return NCollection_Vec4(-x(), -y(), -z(), -w());
+  }
 
   //! Compute per-component subtraction.
-  NCollection_Vec4& operator-=(const NCollection_Vec4& theDec)
+  constexpr NCollection_Vec4& operator-=(const NCollection_Vec4& theDec) noexcept
   {
     v[0] -= theDec.v[0];
     v[1] -= theDec.v[1];
@@ -218,15 +231,15 @@ public:
   }
 
   //! Compute per-component subtraction.
-  friend NCollection_Vec4 operator-(const NCollection_Vec4& theLeft,
-                                    const NCollection_Vec4& theRight)
+  friend constexpr NCollection_Vec4 operator-(const NCollection_Vec4& theLeft,
+                                              const NCollection_Vec4& theRight) noexcept
   {
     NCollection_Vec4 aSumm = NCollection_Vec4(theLeft);
     return aSumm -= theRight;
   }
 
   //! Compute per-component multiplication.
-  NCollection_Vec4& operator*=(const NCollection_Vec4& theRight)
+  constexpr NCollection_Vec4& operator*=(const NCollection_Vec4& theRight) noexcept
   {
     v[0] *= theRight.v[0];
     v[1] *= theRight.v[1];
@@ -236,15 +249,15 @@ public:
   }
 
   //! Compute per-component multiplication.
-  friend NCollection_Vec4 operator*(const NCollection_Vec4& theLeft,
-                                    const NCollection_Vec4& theRight)
+  friend constexpr NCollection_Vec4 operator*(const NCollection_Vec4& theLeft,
+                                              const NCollection_Vec4& theRight) noexcept
   {
     NCollection_Vec4 aResult = NCollection_Vec4(theLeft);
     return aResult *= theRight;
   }
 
   //! Compute per-component multiplication.
-  void Multiply(const Element_t theFactor)
+  constexpr void Multiply(const Element_t theFactor) noexcept
   {
     v[0] *= theFactor;
     v[1] *= theFactor;
@@ -253,17 +266,20 @@ public:
   }
 
   //! Compute per-component multiplication.
-  NCollection_Vec4& operator*=(const Element_t theFactor)
+  constexpr NCollection_Vec4& operator*=(const Element_t theFactor) noexcept
   {
     Multiply(theFactor);
     return *this;
   }
 
   //! Compute per-component multiplication.
-  NCollection_Vec4 operator*(const Element_t theFactor) const { return Multiplied(theFactor); }
+  constexpr NCollection_Vec4 operator*(const Element_t theFactor) const noexcept
+  {
+    return Multiplied(theFactor);
+  }
 
   //! Compute per-component multiplication.
-  NCollection_Vec4 Multiplied(const Element_t theFactor) const
+  constexpr NCollection_Vec4 Multiplied(const Element_t theFactor) const noexcept
   {
     NCollection_Vec4 aCopyVec4(*this);
     aCopyVec4 *= theFactor;
@@ -271,7 +287,7 @@ public:
   }
 
   //! Compute component-wise minimum of two vectors.
-  NCollection_Vec4 cwiseMin(const NCollection_Vec4& theVec) const
+  constexpr NCollection_Vec4 cwiseMin(const NCollection_Vec4& theVec) const noexcept
   {
     return NCollection_Vec4(v[0] < theVec.v[0] ? v[0] : theVec.v[0],
                             v[1] < theVec.v[1] ? v[1] : theVec.v[1],
@@ -280,7 +296,7 @@ public:
   }
 
   //! Compute component-wise maximum of two vectors.
-  NCollection_Vec4 cwiseMax(const NCollection_Vec4& theVec) const
+  constexpr NCollection_Vec4 cwiseMax(const NCollection_Vec4& theVec) const noexcept
   {
     return NCollection_Vec4(v[0] > theVec.v[0] ? v[0] : theVec.v[0],
                             v[1] > theVec.v[1] ? v[1] : theVec.v[1],
@@ -289,13 +305,13 @@ public:
   }
 
   //! Compute component-wise modulus of the vector.
-  NCollection_Vec4 cwiseAbs() const
+  NCollection_Vec4 cwiseAbs() const noexcept
   {
     return NCollection_Vec4(std::abs(v[0]), std::abs(v[1]), std::abs(v[2]), std::abs(v[3]));
   }
 
   //! Compute maximum component of the vector.
-  Element_t maxComp() const
+  constexpr Element_t maxComp() const noexcept
   {
     const Element_t aMax1 = v[0] > v[1] ? v[0] : v[1];
     const Element_t aMax2 = v[2] > v[3] ? v[2] : v[3];
@@ -304,7 +320,7 @@ public:
   }
 
   //! Compute minimum component of the vector.
-  Element_t minComp() const
+  constexpr Element_t minComp() const noexcept
   {
     const Element_t aMin1 = v[0] < v[1] ? v[0] : v[1];
     const Element_t aMin2 = v[2] < v[3] ? v[2] : v[3];
@@ -313,13 +329,13 @@ public:
   }
 
   //! Computes the dot product.
-  Element_t Dot(const NCollection_Vec4& theOther) const
+  constexpr Element_t Dot(const NCollection_Vec4& theOther) const noexcept
   {
     return x() * theOther.x() + y() * theOther.y() + z() * theOther.z() + w() * theOther.w();
   }
 
   //! Compute per-component division by scale factor.
-  NCollection_Vec4& operator/=(const Element_t theInvFactor)
+  constexpr NCollection_Vec4& operator/=(const Element_t theInvFactor)
   {
     v[0] /= theInvFactor;
     v[1] /= theInvFactor;
@@ -329,7 +345,7 @@ public:
   }
 
   //! Compute per-component division.
-  NCollection_Vec4& operator/=(const NCollection_Vec4& theRight)
+  constexpr NCollection_Vec4& operator/=(const NCollection_Vec4& theRight)
   {
     v[0] /= theRight.v[0];
     v[1] /= theRight.v[1];
@@ -339,15 +355,15 @@ public:
   }
 
   //! Compute per-component division by scale factor.
-  NCollection_Vec4 operator/(const Element_t theInvFactor)
+  constexpr NCollection_Vec4 operator/(const Element_t theInvFactor) const
   {
     NCollection_Vec4 aResult(*this);
     return aResult /= theInvFactor;
   }
 
   //! Compute per-component division.
-  friend NCollection_Vec4 operator/(const NCollection_Vec4& theLeft,
-                                    const NCollection_Vec4& theRight)
+  friend constexpr NCollection_Vec4 operator/(const NCollection_Vec4& theLeft,
+                                              const NCollection_Vec4& theRight)
   {
     NCollection_Vec4 aResult = NCollection_Vec4(theLeft);
     return aResult /= theRight;
@@ -366,7 +382,8 @@ private:
 
 //! Optimized concretization for float type.
 template <>
-inline NCollection_Vec4<float>& NCollection_Vec4<float>::operator/=(const float theInvFactor)
+inline constexpr NCollection_Vec4<float>& NCollection_Vec4<float>::operator/=(
+  const float theInvFactor)
 {
   Multiply(1.0f / theInvFactor);
   return *this;
@@ -374,7 +391,8 @@ inline NCollection_Vec4<float>& NCollection_Vec4<float>::operator/=(const float
 
 //! Optimized concretization for double type.
 template <>
-inline NCollection_Vec4<double>& NCollection_Vec4<double>::operator/=(const double theInvFactor)
+inline constexpr NCollection_Vec4<double>& NCollection_Vec4<double>::operator/=(
+  const double theInvFactor)
 {
   Multiply(1.0 / theInvFactor);
   return *this;
index d74ab5658f34f7e269d25edeb93e910bf573333c..d4c5f6ca88e88018032fcaa46cc023febb2393cf 100644 (file)
 // as it is not supported.
 #if defined(__BORLANDC__) || (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530))
   #define DEFINE_STANDARD_ALLOC_PLACEMENT                                                          \
-    void* operator new(size_t, void* theAddress)                                                   \
+    void* operator new(size_t, void* theAddress) noexcept                                          \
     {                                                                                              \
       return theAddress;                                                                           \
     }
 #else
   #define DEFINE_STANDARD_ALLOC_PLACEMENT                                                          \
-    void* operator new(size_t, void* theAddress)                                                   \
+    void* operator new(size_t, void* theAddress) noexcept                                          \
     {                                                                                              \
       return theAddress;                                                                           \
     }                                                                                              \
-    void operator delete(void*, void*) {}
+    void operator delete(void*, void*) noexcept {}
 #endif
 
 // Macro to override operators new and delete to use OCC memory manager
@@ -67,7 +67,7 @@
 #ifndef WORKAROUND_SUNPRO_NEW_PLACEMENT
   #define WORKAROUND_SUNPRO_NEW_PLACEMENT
   #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x420)
-inline void* operator new(size_t, void* anAddress)
+inline void* operator new(size_t, void* anAddress) noexcept
 {
   return anAddress;
 }
index 15d42d57e39ecb9d2c4b256364f390244bd80443..631e46184242f2a55dc00e188312676b1ed4f24b 100644 (file)
   #include <OSD_Timer.hxx>
 #endif
 
-namespace
-{
-static const OpenGl_Vec4 THE_WHITE_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
-static const OpenGl_Vec4 THE_BLACK_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
-} // namespace
-
 namespace
 {
 //! Defines OpenGL texture samplers.
index 81296ae47563ce46dc203e0863bc5e04e208d0a2..5750e203f587b4945d8850c727152540b1946746 100644 (file)
@@ -71,7 +71,6 @@ private:
   bool                                            myToPreferClosest;
 };
 
-static const Graphic3d_Mat4d SelectMgr_ViewerSelector_THE_IDENTITY_MAT;
 } // namespace
 
 //=================================================================================================