Avoid copying Clara::Parser for every inserted Opt

This prevents the full construction from being O(N^2) in number
of `Opt`s, and also reduces the number of allocations for running
no tests significantly:

`tests/SelfTest`: 7705 -> 6095
`tests/ExtraTests/NoTests` 2215 -> 605
This commit is contained in:
Martin Hořeňovský 2023-12-26 11:55:19 +01:00
parent 822c44a203
commit c57e349d1d
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
1 changed files with 8 additions and 2 deletions

View File

@ -636,8 +636,14 @@ namespace Catch {
Parser& operator|=(Parser const& other);
template <typename T>
auto operator|(T const& other) const -> Parser {
return Parser(*this) |= other;
friend Parser operator|(Parser const& p, T const& rhs) {
return Parser( p ) |= rhs;
}
template <typename T>
friend Parser operator|( Parser&& p, T const& rhs ) {
p |= rhs;
return CATCH_MOVE(p);
}
std::vector<Detail::HelpColumns> getHelpColumns() const;