Unverified Commit 4bb0ca65 authored by Alex Langford's avatar Alex Langford Committed by GitHub
Browse files

[Support] Introduce formatv variant of createStringError (#80493)

Many times I have found myself wanting to create a StringError with the
ability to interpolate a StringRef into the error string. This can be
achieved with:

StringRef Foo("...");
auto Err = createStringError(..., "Something went wrong: %s",
Foo.str().c_str());

However, this requires us to construct a temporary std::string (which
may perform a memory allocation if large enough).

I propose a new variant of `createStringError` called
`createStringErrorV` which uses `formatv` under the hood. This allows
the above example to become:

StringRef Foo("...");
auto Err = createStringErrorV(..., "Something went wrong: {0}", Foo);
parent 3d67cf68
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment