Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-12-26 11:55:19 +0100
committerMartin Hořeňovský2023-12-26 15:11:48 +0100
commitc57e349d1d62fcdf96aef576a5c200ae2078daad (patch)
tree39673adb0e665442435aa6bbaf1a4fd934e4bff6 /src/catch2
parent822c44a20395c6194d527110d59f7513a55b885c (diff)
downloadcatch3-c57e349d1d62fcdf96aef576a5c200ae2078daad.tar.gz
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
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/internal/catch_clara.hpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp
index 8f6a4e9e..a9413810 100644
--- a/src/catch2/internal/catch_clara.hpp
+++ b/src/catch2/internal/catch_clara.hpp
@@ -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;