- 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
* 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.
* 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.
/**
* 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;
}
//=================================================================================================
-void Poly_CoherentTriangulation::IteratorOfTriangle::Next()
+void Poly_CoherentTriangulation::IteratorOfTriangle::Next() noexcept
{
Poly_BaseIteratorOfCoherentTriangle::Next();
while (More())
//=================================================================================================
-void Poly_CoherentTriangulation::IteratorOfNode::Next()
+void Poly_CoherentTriangulation::IteratorOfNode::Next() noexcept
{
Poly_BaseIteratorOfCoherentNode::Next();
while (More())
//=================================================================================================
-void Poly_CoherentTriangulation::IteratorOfLink::Next()
+void Poly_CoherentTriangulation::IteratorOfLink::Next() noexcept
{
Poly_BaseIteratorOfCoherentLink::Next();
while (More())
//! Constructor
Standard_EXPORT IteratorOfTriangle(const Handle(Poly_CoherentTriangulation)& theTri);
//! Make step
- Standard_EXPORT virtual void Next();
+ Standard_EXPORT virtual void Next() noexcept;
};
/**
//! Constructor
Standard_EXPORT IteratorOfNode(const Handle(Poly_CoherentTriangulation)& theTri);
//! Make step
- Standard_EXPORT virtual void Next();
+ Standard_EXPORT virtual void Next() noexcept;
};
/**
//! 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()).
NCollection_String.hxx
NCollection_TListIterator.hxx
NCollection_TListNode.hxx
- NCollection_TypeDef.hxx
NCollection_UBTree.hxx
NCollection_UBTreeFiller.hxx
NCollection_UtfIterator.hxx
//=======================================================================
NCollection_AccAllocator::Block* NCollection_AccAllocator::findBlock(
const Standard_Address theAddress,
- Key& theKey)
+ Key& theKey) noexcept
{
theKey = getKey(theAddress);
// --------- 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:
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
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
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)
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;
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:
//=================================================================================================
-NCollection_AlignedAllocator::NCollection_AlignedAllocator(const size_t theAlignment)
+NCollection_AlignedAllocator::NCollection_AlignedAllocator(const size_t theAlignment) noexcept
: myAlignment(theAlignment)
{
//
//! 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;
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
#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.
}
//! 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
//! 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;
}
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)
{
}
//! 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;
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); }
}
//! @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
}
//! 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;
}
myIsOwner = true;
}
- bool IsDeletable() const { return myIsOwner; }
+ bool IsDeletable() const noexcept { return myIsOwner; }
friend iterator;
friend const_iterator;
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));
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;
//! Empty constructor; should be used with caution.
//! @sa methods Resize() and Move().
- NCollection_Array2()
+ NCollection_Array2() noexcept
: NCollection_Array1<TheItemType>(),
myLowerRow(1),
mySizeRow(0),
}
//! 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;
}
//! 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)
{
//! 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));
}
protected:
//! Constructor - prohibited
- NCollection_BaseAllocator() {}
+ NCollection_BaseAllocator() noexcept {}
private:
//! Copy constructor - prohibited
// 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;
// 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;
// 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;
//=================================================================================================
-void NCollection_BaseList::PPrepend(NCollection_BaseList& theOther)
+void NCollection_BaseList::PPrepend(NCollection_BaseList& theOther) noexcept
{
if (this == &theOther || theOther.IsEmpty())
return;
//=================================================================================================
-void NCollection_BaseList::PReverse()
+void NCollection_BaseList::PReverse() noexcept
{
if (myLength > 1)
{
{
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;
// ---------- 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
// ******** 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);
// ******** 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
// ******** PReverse
// Purpose: Reverse the list
- Standard_EXPORT void PReverse();
+ Standard_EXPORT void PReverse() noexcept;
protected:
// ------------ PROTECTED FIELDS ------------
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)
//=================================================================================================
-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);
}
{
protected:
//! Empty constructor
- Iterator(void)
+ Iterator(void) noexcept
: myNbBuckets(0),
myBuckets(nullptr),
myBucket(0),
}
//! Constructor
- Iterator(const NCollection_BaseMap& theMap)
+ Iterator(const NCollection_BaseMap& theMap) noexcept
: myNbBuckets(theMap.myNbBuckets),
myBuckets(theMap.myData1),
myBucket(-1),
public:
//! Initialize
- void Initialize(const NCollection_BaseMap& theMap)
+ void Initialize(const NCollection_BaseMap& theMap) noexcept
{
myNbBuckets = theMap.myNbBuckets;
myBuckets = theMap.myData1;
}
//! Reset
- void Reset(void)
+ void Reset(void) noexcept
{
myBucket = -1;
myNode = nullptr;
}
//! 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;
// ---------- 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 -----------
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);
public:
//! Default constructor
- NCollection_BasePointerVector() {}
+ NCollection_BasePointerVector() noexcept {}
//! Copy data from another vector
Standard_EXPORT NCollection_BasePointerVector(const NCollection_BasePointerVector& theOther);
~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)
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,
// purpose : reverse the order of a given sequence
//=======================================================================
-void NCollection_BaseSequence::PReverse()
+void NCollection_BaseSequence::PReverse() noexcept
{
NCollection_SeqNode* p = myFirstItem;
while (p)
//=================================================================================================
-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;
// 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;
{
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)
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
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
//
Standard_EXPORT NCollection_BaseSequence(const NCollection_BaseSequence& Other);
- void Nullify()
+ void Nullify() noexcept
{
myFirstItem = myLastItem = myCurrentItem = NULL;
myCurrentIndex = mySize = 0;
~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)
}
//! 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++)
}
//! 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++)
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;
}
//! 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);
}
//! 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
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 ------------
//! 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.
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.
: _Array1Type_(theOther) \
{ \
} \
- const _Array1Type_& Array1() const \
+ const _Array1Type_& Array1() const noexcept \
{ \
return *this; \
} \
- _Array1Type_& ChangeArray1() \
+ _Array1Type_& ChangeArray1() noexcept \
{ \
return *this; \
} \
: _Array2Type_(theOther) \
{ \
} \
- const _Array2Type_& Array2() const \
+ const _Array2Type_& Array2() const noexcept \
{ \
return *this; \
} \
- _Array2Type_& ChangeArray2() \
+ _Array2Type_& ChangeArray2() noexcept \
{ \
return *this; \
} \
: _SequenceType_(theOther) \
{ \
} \
- const _SequenceType_& Sequence() const \
+ const _SequenceType_& Sequence() const noexcept \
{ \
return *this; \
} \
{ \
_SequenceType_::Append(theSequence); \
} \
- _SequenceType_& ChangeSequence() \
+ _SequenceType_& ChangeSequence() noexcept \
{ \
return *this; \
} \
}
//! 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);
}
//! 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
//! 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.
~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
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)
~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,
}
//! 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)
myUsedSize = 0;
}
- void SetIncrement(const Standard_Integer theIncrement)
+ void SetIncrement(const Standard_Integer theIncrement) noexcept
{
if (myUsedSize != 0)
{
friend const_iterator;
protected:
- size_t availableSize() const { return myContainer.Size() * myInternalSize; }
+ size_t availableSize() const noexcept { return myContainer.Size() * myInternalSize; }
TheItemType* expandArray()
{
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];
}
}
//! Wrapper to extract array
- TheItemType** getArray() const { return (TheItemType**)myContainer.GetArray(); }
+ TheItemType** getArray() const noexcept { return (TheItemType**)myContainer.GetArray(); }
protected:
vector myContainer;
\
/* 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(); \
} \
}
//! 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);
}
}
//! 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);
}
//! 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
}
//! 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;
}
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 ------------
//! 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.
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.
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))
{
//! 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)
{
//! 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;
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;
}
template <bool theOtherIsConstant>
bool operator==(
const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, theOtherIsConstant>&
- theOther) const
+ theOther) const noexcept
{
return myIndexedMap == theOther.myIndexedMap && myIndex == theOther.myIndex;
}
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);
}
}
//! 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);
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
}
//! Postfix decrement
- NCollection_IndexedIterator operator--(int)
+ NCollection_IndexedIterator operator--(int) noexcept
{
NCollection_IndexedIterator theOld(*this);
--(*this);
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));
//! 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;
//! 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;
//! 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));
}
//! 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>;
}
//! 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);
}
//! 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
}
//! 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;
}
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 ------------
//! 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.
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.
{
}
- ~NCollection_Iterator() {}
+ ~NCollection_Iterator() noexcept {}
void Init(Container& theList)
{
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)
{
return *this;
}
- NCollection_Iterator& operator=(NCollection_Iterator&& theOther)
+ NCollection_Iterator& operator=(NCollection_Iterator&& theOther) noexcept
{
if (this != &theOther)
{
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 ------------
}
//! 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.
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
Allocate(theSize);
}
- NCollection_LocalArray()
+ NCollection_LocalArray() noexcept
: myPtr(myBuffer),
mySize(0)
{
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&);
}
//! Key
- const TheKeyType& Key(void) { return this->Value(); }
+ const TheKeyType& Key(void) noexcept { return this->Value(); }
};
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
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 ------------
//! 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.
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.
{
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();
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,
//! @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);
}
//! @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];
}
//! @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];
}
//! @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),
//! 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());
}
//! 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),
//! 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());
//! 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());
}
//! 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(),
//! 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);
//! 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;
//! 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);
}
//! 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;
//! 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)
{
//! 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;
//! 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);
}
//! 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;
//! 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)
{
//! 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;
}
//! 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)
{
}
//! 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)
{
}
//! 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;
}
//! 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;
}
//! 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)
}
//! 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));
}
//! 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)
}
//! 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)));
//! 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)
{
}
//! 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);
}
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>
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();
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,
//! @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);
}
//! @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];
}
//! @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];
}
//! @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);
}
//! 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),
//! 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());
//! 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());
//! 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),
//! 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());
//! 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());
//! 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),
//! 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());
//! 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());
}
//! 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());
}
//! 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()
//! 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);
//! 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;
//! 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);
}
//! 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;
//! 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)
{
//! 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;
//! 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);
}
//! 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;
//! 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)
{
//! 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;
}
//! 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)
{
}
//! 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)
{
}
//! 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;
}
//! 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;
}
//! 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)
}
//! 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);
//! 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));
}
//! Transpose the matrix.
- void Transpose() { *this = Transposed(); }
+ constexpr void Transpose() noexcept { *this = Transposed(); }
//! Compute inverted matrix.
//! @param[out] theOutMx the inverted matrix
}
//! 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)
}
//! 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)));
//! 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)
{
//! 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);
}
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());
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>
#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
//! 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)
{
}
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)
}
//! 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();
//! 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;
}
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();
}
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;
}
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
}
//! 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;
}
//! 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)
{
}
//! 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;
}
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();
}
//! 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();
}
//! 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(); }
{
public:
//! Constructor; accepts size of blocks
- explicit NCollection_SparseArray(Standard_Size theIncrement)
+ explicit NCollection_SparseArray(Standard_Size theIncrement) noexcept
: NCollection_SparseArrayBase(sizeof(TheItemType), theIncrement)
{
}
//!@{
//! 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); }
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(); }
};
/**
#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
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;
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
}
//! 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())
//! 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);
}
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()));
}
//! 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()));
//! 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()));
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
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;
// 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),
// 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;
}
}
//! 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
{
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();
}
}
//! 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)
+++ /dev/null
-// 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
* @return
* True signals that the selection process is stopped
*/
- Standard_Boolean Stop() const { return myStop; }
+ Standard_Boolean Stop() const noexcept { return myStop; }
/**
* Destructor
{
}
- 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
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.
* @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 ----------
* @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.
ChangeTree().Clear(); \
} \
\
- Standard_Boolean IsEmpty() const \
+ Standard_Boolean IsEmpty() const noexcept \
{ \
return Tree().IsEmpty(); \
} \
\
/* Access to the tree algorithm */ \
\
- const UBTree& Tree() const \
+ const UBTree& Tree() const noexcept \
{ \
return *myTree; \
} \
- UBTree& ChangeTree() \
+ UBTree& ChangeTree() noexcept \
{ \
return *myTree; \
} \
}
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,
}
//! 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;
//! @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));
}
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); }
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
// 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.
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>
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.
~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
//! 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;
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();
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)
}
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
//! 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);
}
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);
//=================================================================================================
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
//=================================================================================================
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);
// 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));
}
//! 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()); \
}
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;
//! @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];
}
//! 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];
}
//! 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];
}
//! 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;
}
//! 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];
}
//! 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
//! 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()); \
}
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;
}
//! 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];
//! @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]);
}
//! 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;
}
//! 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();
}
//! 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)
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];
}
//! 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];
}
//! 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;
}
//! 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];
}
//! 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;
}
//! 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],
}
//! 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],
}
//! 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;
}
//! 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];
}
//! 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()
}
//! 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(),
//! 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));
}
//! 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;
//! 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;
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;
}
//! 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];
//! @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]);
}
//! 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;
}
//! 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();
}
//! 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)
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];
}
//! 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];
}
//! 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];
}
//! 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;
}
//! 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;
}
//! 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],
}
//! 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],
}
//! 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];
}
//! 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];
}
//! 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;
}
//! 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];
}
//! 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;
//! 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;
//! 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;
// 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
#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;
}
#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.
bool myToPreferClosest;
};
-static const Graphic3d_Mat4d SelectMgr_ViewerSelector_THE_IDENTITY_MAT;
} // namespace
//=================================================================================================