mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 14:28:30 +00:00
Add missing ctl::string append method
This commit is contained in:
parent
a120bc7149
commit
bd6630d62d
3 changed files with 16 additions and 1 deletions
|
@ -383,4 +383,10 @@ string::erase(const size_t pos, size_t count) noexcept
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
string::append(const ctl::string_view& s, size_t pos, size_t count) noexcept
|
||||||
|
{
|
||||||
|
append(s.substr(pos, count));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ctl
|
} // namespace ctl
|
||||||
|
|
|
@ -125,6 +125,7 @@ class string
|
||||||
void append(char, size_t) noexcept;
|
void append(char, size_t) noexcept;
|
||||||
void append(unsigned long) noexcept;
|
void append(unsigned long) noexcept;
|
||||||
void append(const void*, size_t) noexcept;
|
void append(const void*, size_t) noexcept;
|
||||||
|
void append(const ctl::string_view&, size_t, size_t = npos) noexcept;
|
||||||
string& insert(size_t, ctl::string_view) noexcept;
|
string& insert(size_t, ctl::string_view) noexcept;
|
||||||
string& erase(size_t = 0, size_t = npos) noexcept;
|
string& erase(size_t = 0, size_t = npos) noexcept;
|
||||||
string substr(size_t = 0, size_t = npos) const noexcept;
|
string substr(size_t = 0, size_t = npos) const noexcept;
|
||||||
|
@ -302,7 +303,7 @@ class string
|
||||||
append(ch);
|
append(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void append(const ctl::string_view s) noexcept
|
void append(const ctl::string_view& s) noexcept
|
||||||
{
|
{
|
||||||
append(s.p, s.n);
|
append(s.p, s.n);
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,5 +404,13 @@ main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
String s = "love";
|
||||||
|
String b;
|
||||||
|
b.append(s, 1, 2);
|
||||||
|
if (b != "ov")
|
||||||
|
return 107;
|
||||||
|
}
|
||||||
|
|
||||||
CheckForMemoryLeaks();
|
CheckForMemoryLeaks();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue