util/AllocatedString: add noexcept
This commit is contained in:
parent
a8687fb7df
commit
f04a245769
@ -55,24 +55,25 @@ public:
|
|||||||
private:
|
private:
|
||||||
pointer value;
|
pointer value;
|
||||||
|
|
||||||
explicit AllocatedString(pointer _value)
|
explicit AllocatedString(pointer _value) noexcept
|
||||||
:value(_value) {}
|
:value(_value) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AllocatedString(std::nullptr_t n):value(n) {}
|
AllocatedString(std::nullptr_t n) noexcept
|
||||||
|
:value(n) {}
|
||||||
|
|
||||||
AllocatedString(AllocatedString &&src)
|
AllocatedString(AllocatedString &&src) noexcept
|
||||||
:value(src.Steal()) {}
|
:value(src.Steal()) {}
|
||||||
|
|
||||||
~AllocatedString() {
|
~AllocatedString() noexcept {
|
||||||
delete[] value;
|
delete[] value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AllocatedString Donate(pointer value) {
|
static AllocatedString Donate(pointer value) noexcept {
|
||||||
return AllocatedString(value);
|
return AllocatedString(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AllocatedString Null() {
|
static AllocatedString Null() noexcept {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,44 +99,44 @@ public:
|
|||||||
return Donate(p);
|
return Donate(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatedString &operator=(AllocatedString &&src) {
|
AllocatedString &operator=(AllocatedString &&src) noexcept {
|
||||||
std::swap(value, src.value);
|
std::swap(value, src.value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool operator==(std::nullptr_t) const {
|
constexpr bool operator==(std::nullptr_t) const noexcept {
|
||||||
return value == nullptr;
|
return value == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool operator!=(std::nullptr_t) const {
|
constexpr bool operator!=(std::nullptr_t) const noexcept {
|
||||||
return value != nullptr;
|
return value != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool IsNull() const {
|
constexpr bool IsNull() const noexcept {
|
||||||
return value == nullptr;
|
return value == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const_pointer c_str() const {
|
constexpr const_pointer c_str() const noexcept {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const {
|
bool empty() const noexcept {
|
||||||
return *value == SENTINEL;
|
return *value == SENTINEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr pointer data() const {
|
constexpr pointer data() const noexcept {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
reference operator[](size_type i) {
|
reference operator[](size_type i) noexcept {
|
||||||
return value[i];
|
return value[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
const reference operator[](size_type i) const {
|
const reference operator[](size_type i) const noexcept {
|
||||||
return value[i];
|
return value[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer Steal() {
|
pointer Steal() noexcept {
|
||||||
return std::exchange(value, nullptr);
|
return std::exchange(value, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user