- size_t n = std::min(this->size(), that.size());
- int res = memcmp(this->c_str(), that.c_str(), n);
- if (res != 0)
- return res;
- else if (this->size() == that.size())
- return 0;
- else if (this->size() < that.size())
- return -1;
- else
- return 1;
+ if (pos > str.len)
+ throw std::out_of_range(string_printf("xbt::string::copy with pos > size() (%zu > %zu)", pos, str.len));
+ size_t count = std::min(len, str.len - pos);
+ std::copy_n(str.data + pos, count, s);
+ return count;
+ }
+
+ bool equals(const char* data, std::size_t len) const
+ {
+ return this->size() == len
+ && std::memcmp(this->c_str(), data, len) == 0;