| 65 | } |
| 66 | |
| 67 | char const* String::c_str() |
| 68 | { |
| 69 | char const* c = this->data(); |
| 70 | if (!c) { |
| 71 | return c; |
| 72 | } |
| 73 | |
| 74 | // We always point into a null-terminated string so it is safe to |
| 75 | // access one past the end. If it is a null byte then we can use |
| 76 | // the pointer directly. |
| 77 | if (c[this->size()] == '\0') { |
| 78 | return c; |
| 79 | } |
| 80 | |
| 81 | // Mutate to hold a std::string so we can get a null terminator. |
| 82 | this->internally_mutate_to_stable_string(); |
| 83 | c = this->string_->c_str(); |
| 84 | return c; |
| 85 | } |
| 86 | |
| 87 | String& String::insert(size_type index, size_type count, char ch) |
| 88 | { |