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:
kgv
2017-10-15 16:08:01 +03:00
committed by bugmaster
parent 4ecf34cce7
commit 6286195cff
9 changed files with 209 additions and 22 deletions

View File

@@ -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);