Codechange: make creating temporary StringParameters easier #11007
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
The repetitiveness of:
Description
Introduce a sub class of StringParameters that has its own buffer.
Introduce a templated method that can accept any number of arguments that creates and fills the appropriate "StringParameters" instance.
Use that templated function instead, so the above code becomes
auto tmp_params = MakeParameters(this->index);
.As added bonus, stuff like:
becomes
auto tmp_params = MakeParameters(e->name);
, by implementingSetParam
forconst std::string&
andconst char *
.Limitations
None I can think of, except that there are a few other places where this new class could be used. However, those are for a later PR.
String pointers/references are still cast to
size_t
and thenuint64_t
. Solving that is, again, for a later PR.I would have liked to use
std::array
and rely on copy-elision. That does work with GCC, but neither Clang nor MSVC does copy-elision forMakeParameters
making that route troublesome. So, I've gone withstd::vector
so it can just move a pointer around.Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.