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

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJoe Burzinski2019-12-15 00:16:04 -0600
committerMartin Hořeňovský2020-02-13 16:19:50 +0100
commit82baef62e2cc6766915e2278309e41cab514f53d (patch)
tree8a8f74f8b1731f62c6d0da6073e7643beed27f34 /src
parent0fbf4f3e152e8fe9a41fa1a960ea3dac3cb76e59 (diff)
downloadcatch3-82baef62e2cc6766915e2278309e41cab514f53d.tar.gz
Fix forwarding in SingleValueGenerator and generator creation
Fixes #1809
Diffstat (limited to 'src')
-rw-r--r--src/catch2/catch_generators.hpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/catch2/catch_generators.hpp b/src/catch2/catch_generators.hpp
index de0b354d..86f02006 100644
--- a/src/catch2/catch_generators.hpp
+++ b/src/catch2/catch_generators.hpp
@@ -49,7 +49,6 @@ namespace Generators {
class SingleValueGenerator final : public IGenerator<T> {
T m_value;
public:
- SingleValueGenerator(T const& value) : m_value( value ) {}
SingleValueGenerator(T&& value) : m_value(std::move(value)) {}
T const& get() const override {
@@ -112,21 +111,21 @@ namespace Generators {
m_generators.emplace_back(std::move(generator));
}
void populate(T&& val) {
- m_generators.emplace_back(value(std::move(val)));
+ m_generators.emplace_back(value(std::forward<T>(val)));
}
template<typename U>
void populate(U&& val) {
- populate(T(std::move(val)));
+ populate(T(std::forward<U>(val)));
}
template<typename U, typename... Gs>
- void populate(U&& valueOrGenerator, Gs... moreGenerators) {
+ void populate(U&& valueOrGenerator, Gs &&... moreGenerators) {
populate(std::forward<U>(valueOrGenerator));
populate(std::forward<Gs>(moreGenerators)...);
}
public:
template <typename... Gs>
- Generators(Gs... moreGenerators) {
+ Generators(Gs &&... moreGenerators) {
m_generators.reserve(sizeof...(Gs));
populate(std::forward<Gs>(moreGenerators)...);
}
@@ -158,7 +157,7 @@ namespace Generators {
struct as {};
template<typename T, typename... Gs>
- auto makeGenerators( GeneratorWrapper<T>&& generator, Gs... moreGenerators ) -> Generators<T> {
+ auto makeGenerators( GeneratorWrapper<T>&& generator, Gs &&... moreGenerators ) -> Generators<T> {
return Generators<T>(std::move(generator), std::forward<Gs>(moreGenerators)...);
}
template<typename T>
@@ -166,11 +165,11 @@ namespace Generators {
return Generators<T>(std::move(generator));
}
template<typename T, typename... Gs>
- auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators<T> {
+ auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<T> {
return makeGenerators( value( std::forward<T>( val ) ), std::forward<Gs>( moreGenerators )... );
}
template<typename T, typename U, typename... Gs>
- auto makeGenerators( as<T>, U&& val, Gs... moreGenerators ) -> Generators<T> {
+ auto makeGenerators( as<T>, U&& val, Gs &&... moreGenerators ) -> Generators<T> {
return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... );
}