AK: Remove default parameter from StringBuilder's constructor
This separates the StringBuilder constructor into 2 constructors. This
essentially allows forming code of the following pattern:
StringBuilder foo() { return {}; }
Otherwise, we would get the following compiler error:
chosen constructor is explicit in copy-initialization
Due to the explicitness of the StringBuilder constructor.
This is required for an upcoming update to ICU 76, where we use our
StringBuilder in templated ICU code.
This commit is contained in:
parent
e5d521bef8
commit
c2741ea85e
2 changed files with 7 additions and 1 deletions
|
|
@ -40,6 +40,11 @@ ErrorOr<StringBuilder> StringBuilder::create(size_t initial_capacity)
|
|||
return StringBuilder { move(buffer) };
|
||||
}
|
||||
|
||||
StringBuilder::StringBuilder()
|
||||
: StringBuilder(inline_capacity)
|
||||
{
|
||||
}
|
||||
|
||||
StringBuilder::StringBuilder(size_t initial_capacity)
|
||||
: m_buffer(MUST(create_buffer(initial_capacity)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ public:
|
|||
|
||||
static ErrorOr<StringBuilder> create(size_t initial_capacity = inline_capacity);
|
||||
|
||||
explicit StringBuilder(size_t initial_capacity = inline_capacity);
|
||||
StringBuilder();
|
||||
explicit StringBuilder(size_t initial_capacity);
|
||||
~StringBuilder() = default;
|
||||
|
||||
ErrorOr<void> try_append(StringView);
|
||||
|
|
|
|||
Loading…
Reference in a new issue