util/AllocatedString: add operator=()
This commit is contained in:
		
				
					committed by
					
						
						Max Kellermann
					
				
			
			
				
	
			
			
			
						parent
						
							c1a7aa652d
						
					
				
				
					commit
					0ded23591b
				
			@@ -100,6 +100,18 @@ public:
 | 
			
		||||
		return *this;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	BasicAllocatedString &operator=(std::string_view src) noexcept {
 | 
			
		||||
		delete[] std::exchange(value, nullptr);
 | 
			
		||||
		value = Duplicate(src);
 | 
			
		||||
		return *this;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	BasicAllocatedString &operator=(const char *src) noexcept {
 | 
			
		||||
		delete[] std::exchange(value, nullptr);
 | 
			
		||||
		value = src != nullptr ? Duplicate(src) : nullptr;
 | 
			
		||||
		return *this;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	constexpr bool operator==(std::nullptr_t) const noexcept {
 | 
			
		||||
		return value == nullptr;
 | 
			
		||||
	}
 | 
			
		||||
@@ -161,6 +173,8 @@ public:
 | 
			
		||||
	AllocatedString() noexcept = default;
 | 
			
		||||
	AllocatedString(BasicAllocatedString<value_type> &&src) noexcept
 | 
			
		||||
		:BasicAllocatedString(std::move(src)) {}
 | 
			
		||||
 | 
			
		||||
	using BasicAllocatedString::operator=;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user