mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-12 01:50:22 +08:00
0029258: Foundation Classes - provide move constructors for string classes
New macro OCCT_NO_RVALUE_REFERENCE is introduced to disable methods using move semantics on obsolete compilers that do not support rvalue references. TCollection_AsciiString, TCollection_ExtendedString, NCollection_UtfString - added method Swap(), move constructor, and move assignment operator. Draw command QATestArrayMove is added to test for memory corruption if NCollection_Array1<> bound to local C buffer is returned from function by value.
This commit is contained in:
@@ -80,6 +80,11 @@ public:
|
||||
//! @param theCopy string to copy.
|
||||
NCollection_UtfString (const NCollection_UtfString& theCopy);
|
||||
|
||||
#ifndef OCCT_NO_RVALUE_REFERENCE
|
||||
//! Move constructor
|
||||
NCollection_UtfString (NCollection_UtfString&& theOther);
|
||||
#endif
|
||||
|
||||
//! Copy constructor from UTF-8 string.
|
||||
//! @param theCopyUtf8 UTF-8 string to copy
|
||||
//! @param theLength optional length limit in Unicode symbols (NOT bytes!)
|
||||
@@ -196,7 +201,18 @@ public:
|
||||
public: //! @name assign operators
|
||||
|
||||
//! Copy from another string.
|
||||
const NCollection_UtfString& operator= (const NCollection_UtfString& theOther);
|
||||
const NCollection_UtfString& Assign (const NCollection_UtfString& theOther);
|
||||
|
||||
//! Exchange the data of two strings (without reallocating memory).
|
||||
void Swap (NCollection_UtfString& theOther);
|
||||
|
||||
//! Copy from another string.
|
||||
const NCollection_UtfString& operator= (const NCollection_UtfString& theOther) { return Assign (theOther); }
|
||||
|
||||
#ifndef OCCT_NO_RVALUE_REFERENCE
|
||||
//! Move assignment operator.
|
||||
NCollection_UtfString& operator= (NCollection_UtfString&& theOther) { Swap (theOther); return *this; }
|
||||
#endif
|
||||
|
||||
//! Copy from UTF-8 NULL-terminated string.
|
||||
const NCollection_UtfString& operator= (const char* theStringUtf8);
|
||||
|
||||
Reference in New Issue
Block a user