1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +03:00

WString: mark move ctor as noexcept (#7610)

ref.
- https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-move-noexcept
- https://rules.sonarsource.com/cpp/RSPEC-5018?search=noexecept
- https://clang.llvm.org/extra/clang-tidy/checks/performance-noexcept-move-constructor.html

> Move constructors of all the types used with STL containers, for
example, need to be declared noexcept. Otherwise STL will choose copy
constructors instead. The same is valid for move assignment operations.
This commit is contained in:
Max Prokhorov 2020-09-24 05:35:32 +03:00 committed by GitHub
parent 4a24d3cc16
commit c24109fd57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -46,12 +46,12 @@ String::String(const __FlashStringHelper *pstr) {
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String::String(String &&rval) {
String::String(String &&rval) noexcept {
init();
move(rval);
}
String::String(StringSumHelper &&rval) {
String::String(StringSumHelper &&rval) noexcept {
init();
move(rval);
}
@ -224,7 +224,7 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length) {
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void String::move(String &rhs) {
void String::move(String &rhs) noexcept {
if (buffer()) {
if (capacity() >= rhs.len()) {
memmove_P(wbuffer(), rhs.buffer(), rhs.length() + 1);
@ -267,13 +267,13 @@ String & String::operator =(const String &rhs) {
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String & String::operator =(String &&rval) {
String & String::operator =(String &&rval) noexcept {
if (this != &rval)
move(rval);
return *this;
}
String & String::operator =(StringSumHelper &&rval) {
String & String::operator =(StringSumHelper &&rval) noexcept {
if (this != &rval)
move(rval);
return *this;

View File

@ -57,8 +57,8 @@ class String {
String(const String &str);
String(const __FlashStringHelper *str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String(String &&rval);
String(StringSumHelper &&rval);
String(String &&rval) noexcept;
String(StringSumHelper &&rval) noexcept;
#endif
explicit String(char c);
explicit String(unsigned char, unsigned char base = 10);
@ -96,8 +96,8 @@ class String {
String & operator =(const char *cstr);
String & operator = (const __FlashStringHelper *str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String & operator =(String &&rval);
String & operator =(StringSumHelper &&rval);
String & operator =(String &&rval) noexcept;
String & operator =(StringSumHelper &&rval) noexcept;
#endif
// concatenate (works w/ built-in types)
@ -317,7 +317,7 @@ class String {
String & copy(const char *cstr, unsigned int length);
String & copy(const __FlashStringHelper *pstr, unsigned int length);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void move(String &rhs);
void move(String &rhs) noexcept;
#endif
};