Replace uses of std::move and std::forward with macros

This improves the SelfTest build times by about 3% (measured
with Clang 10 on random Linux box I had lying around).
This commit is contained in:
Martin Hořeňovský 2021-08-13 14:16:30 +02:00
parent 03ce304102
commit d2ee7100d2
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
41 changed files with 156 additions and 129 deletions

View File

@ -15,7 +15,7 @@
#include <catch2/internal/catch_context.hpp> #include <catch2/internal/catch_context.hpp>
#include <catch2/interfaces/catch_interfaces_reporter.hpp> #include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <catch2/internal/catch_unique_name.hpp> #include <catch2/internal/catch_unique_name.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/benchmark/catch_chronometer.hpp> #include <catch2/benchmark/catch_chronometer.hpp>
#include <catch2/benchmark/catch_clock.hpp> #include <catch2/benchmark/catch_clock.hpp>
#include <catch2/benchmark/catch_environment.hpp> #include <catch2/benchmark/catch_environment.hpp>
@ -36,11 +36,11 @@ namespace Catch {
namespace Benchmark { namespace Benchmark {
struct Benchmark { struct Benchmark {
Benchmark(std::string&& benchmarkName) Benchmark(std::string&& benchmarkName)
: name(std::move(benchmarkName)) {} : name(CATCH_MOVE(benchmarkName)) {}
template <class FUN> template <class FUN>
Benchmark(std::string&& benchmarkName , FUN &&func) Benchmark(std::string&& benchmarkName , FUN &&func)
: fun(std::move(func)), name(std::move(benchmarkName)) {} : fun(CATCH_MOVE(func)), name(CATCH_MOVE(benchmarkName)) {}
template <typename Clock> template <typename Clock>
ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const { ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const {

View File

@ -14,6 +14,7 @@
#include <catch2/benchmark/catch_optimizer.hpp> #include <catch2/benchmark/catch_optimizer.hpp>
#include <catch2/benchmark/detail/catch_complete_invoke.hpp> #include <catch2/benchmark/detail/catch_complete_invoke.hpp>
#include <catch2/internal/catch_meta.hpp> #include <catch2/internal/catch_meta.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
namespace Benchmark { namespace Benchmark {
@ -42,7 +43,7 @@ namespace Catch {
struct Chronometer { struct Chronometer {
public: public:
template <typename Fun> template <typename Fun>
void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); } void measure(Fun&& fun) { measure(CATCH_FORWARD(fun), is_callable<Fun(int)>()); }
int runs() const { return repeats; } int runs() const { return repeats; }

View File

@ -10,8 +10,9 @@
#ifndef CATCH_CONSTRUCTOR_HPP_INCLUDED #ifndef CATCH_CONSTRUCTOR_HPP_INCLUDED
#define CATCH_CONSTRUCTOR_HPP_INCLUDED #define CATCH_CONSTRUCTOR_HPP_INCLUDED
#include <catch2/internal/catch_move_and_forward.hpp>
#include <type_traits> #include <type_traits>
#include <utility>
namespace Catch { namespace Catch {
namespace Benchmark { namespace Benchmark {
@ -30,7 +31,7 @@ namespace Catch {
ObjectStorage(ObjectStorage&& other) ObjectStorage(ObjectStorage&& other)
{ {
new(&data) T(std::move(other.stored_object())); new(&data) T(CATCH_MOVE(other.stored_object()));
} }
~ObjectStorage() { destruct_on_exit<T>(); } ~ObjectStorage() { destruct_on_exit<T>(); }
@ -38,7 +39,7 @@ namespace Catch {
template <typename... Args> template <typename... Args>
void construct(Args&&... args) void construct(Args&&... args)
{ {
new (&data) T(std::forward<Args>(args)...); new (&data) T(CATCH_FORWARD(args)...);
} }
template <bool AllowManualDestruction = !Destruct> template <bool AllowManualDestruction = !Destruct>

View File

@ -14,8 +14,9 @@
# include <atomic> // atomic_thread_fence # include <atomic> // atomic_thread_fence
#endif #endif
#include <catch2/internal/catch_move_and_forward.hpp>
#include <type_traits> #include <type_traits>
#include <utility>
namespace Catch { namespace Catch {
namespace Benchmark { namespace Benchmark {
@ -57,12 +58,12 @@ namespace Catch {
template <typename Fn, typename... Args> template <typename Fn, typename... Args>
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<!std::is_same<void, decltype(fn(args...))>::value>::type { inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<!std::is_same<void, decltype(fn(args...))>::value>::type {
deoptimize_value(std::forward<Fn>(fn) (std::forward<Args...>(args...))); deoptimize_value(CATCH_FORWARD(fn) (CATCH_FORWARD(args)...));
} }
template <typename Fn, typename... Args> template <typename Fn, typename... Args>
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<std::is_same<void, decltype(fn(args...))>::value>::type { inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<std::is_same<void, decltype(fn(args...))>::value>::type {
std::forward<Fn>(fn) (std::forward<Args...>(args...)); CATCH_FORWARD(fn) (CATCH_FORWARD(args)...);
} }
} // namespace Benchmark } // namespace Benchmark
} // namespace Catch } // namespace Catch

View File

@ -13,10 +13,10 @@
#include <catch2/benchmark/catch_clock.hpp> #include <catch2/benchmark/catch_clock.hpp>
#include <catch2/benchmark/catch_estimate.hpp> #include <catch2/benchmark/catch_estimate.hpp>
#include <catch2/benchmark/catch_outlier_classification.hpp> #include <catch2/benchmark/catch_outlier_classification.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <string>
#include <iterator> #include <iterator>
namespace Catch { namespace Catch {
@ -35,7 +35,7 @@ namespace Catch {
samples2.reserve(samples.size()); samples2.reserve(samples.size());
std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); });
return { return {
std::move(samples2), CATCH_MOVE(samples2),
mean, mean,
standard_deviation, standard_deviation,
outliers, outliers,

View File

@ -15,6 +15,7 @@
#include <catch2/benchmark/catch_sample_analysis.hpp> #include <catch2/benchmark/catch_sample_analysis.hpp>
#include <catch2/benchmark/detail/catch_stats.hpp> #include <catch2/benchmark/detail/catch_stats.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp> #include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
@ -45,7 +46,7 @@ namespace Catch {
samples2.reserve(samples.size()); samples2.reserve(samples.size());
std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); });
return { return {
std::move(samples2), CATCH_MOVE(samples2),
wrap_estimate(analysis.mean), wrap_estimate(analysis.mean),
wrap_estimate(analysis.standard_deviation), wrap_estimate(analysis.standard_deviation),
outliers, outliers,
@ -64,7 +65,7 @@ namespace Catch {
mean /= i; mean /= i;
return { return {
std::move(samples), CATCH_MOVE(samples),
Estimate<Duration>{mean, mean, mean, 0.0}, Estimate<Duration>{mean, mean, mean, 0.0},
Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0}, Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0},
OutlierClassification{}, OutlierClassification{},

View File

@ -14,8 +14,8 @@
#include <catch2/benchmark/detail/catch_complete_invoke.hpp> #include <catch2/benchmark/detail/catch_complete_invoke.hpp>
#include <catch2/internal/catch_meta.hpp> #include <catch2/internal/catch_meta.hpp>
#include <catch2/internal/catch_unique_ptr.hpp> #include <catch2/internal/catch_unique_ptr.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <cassert>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
@ -48,7 +48,7 @@ namespace Catch {
}; };
template <typename Fun> template <typename Fun>
struct model : public callable { struct model : public callable {
model(Fun&& fun_) : fun(std::move(fun_)) {} model(Fun&& fun_) : fun(CATCH_MOVE(fun_)) {}
model(Fun const& fun_) : fun(fun_) {} model(Fun const& fun_) : fun(fun_) {}
model<Fun>* clone() const override { return new model<Fun>(*this); } model<Fun>* clone() const override { return new model<Fun>(*this); }
@ -78,17 +78,17 @@ namespace Catch {
template <typename Fun, template <typename Fun,
typename std::enable_if<!is_related<Fun, BenchmarkFunction>::value, int>::type = 0> typename std::enable_if<!is_related<Fun, BenchmarkFunction>::value, int>::type = 0>
BenchmarkFunction(Fun&& fun) BenchmarkFunction(Fun&& fun)
: f(new model<typename std::decay<Fun>::type>(std::forward<Fun>(fun))) {} : f(new model<typename std::decay<Fun>::type>(CATCH_FORWARD(fun))) {}
BenchmarkFunction( BenchmarkFunction&& that ) noexcept: BenchmarkFunction( BenchmarkFunction&& that ) noexcept:
f( std::move( that.f ) ) {} f( CATCH_MOVE( that.f ) ) {}
BenchmarkFunction(BenchmarkFunction const& that) BenchmarkFunction(BenchmarkFunction const& that)
: f(that.f->clone()) {} : f(that.f->clone()) {}
BenchmarkFunction& BenchmarkFunction&
operator=( BenchmarkFunction&& that ) noexcept { operator=( BenchmarkFunction&& that ) noexcept {
f = std::move( that.f ); f = CATCH_MOVE( that.f );
return *this; return *this;
} }

View File

@ -14,6 +14,7 @@
#include <catch2/internal/catch_meta.hpp> #include <catch2/internal/catch_meta.hpp>
#include <catch2/interfaces/catch_interfaces_capture.hpp> #include <catch2/interfaces/catch_interfaces_capture.hpp>
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp> #include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
@ -33,14 +34,14 @@ namespace Catch {
struct CompleteInvoker { struct CompleteInvoker {
template <typename Fun, typename... Args> template <typename Fun, typename... Args>
static Result invoke(Fun&& fun, Args&&... args) { static Result invoke(Fun&& fun, Args&&... args) {
return std::forward<Fun>(fun)(std::forward<Args>(args)...); return CATCH_FORWARD(fun)(CATCH_FORWARD(args)...);
} }
}; };
template <> template <>
struct CompleteInvoker<void> { struct CompleteInvoker<void> {
template <typename Fun, typename... Args> template <typename Fun, typename... Args>
static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) { static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) {
std::forward<Fun>(fun)(std::forward<Args>(args)...); CATCH_FORWARD(fun)(CATCH_FORWARD(args)...);
return {}; return {};
} }
}; };
@ -48,14 +49,14 @@ namespace Catch {
// invoke and not return void :( // invoke and not return void :(
template <typename Fun, typename... Args> template <typename Fun, typename... Args>
CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) { CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) {
return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...); return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...);
} }
} // namespace Detail } // namespace Detail
template <typename Fun> template <typename Fun>
Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) { Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) {
return Detail::complete_invoke(std::forward<Fun>(fun)); return Detail::complete_invoke(CATCH_FORWARD(fun));
} }
} // namespace Benchmark } // namespace Benchmark
} // namespace Catch } // namespace Catch

View File

@ -13,8 +13,7 @@
#include <catch2/benchmark/catch_clock.hpp> #include <catch2/benchmark/catch_clock.hpp>
#include <catch2/benchmark/detail/catch_complete_invoke.hpp> #include <catch2/benchmark/detail/catch_complete_invoke.hpp>
#include <catch2/benchmark/detail/catch_timing.hpp> #include <catch2/benchmark/detail/catch_timing.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <utility>
namespace Catch { namespace Catch {
namespace Benchmark { namespace Benchmark {
@ -22,10 +21,10 @@ namespace Catch {
template <typename Clock, typename Fun, typename... Args> template <typename Clock, typename Fun, typename... Args>
TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) { TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) {
auto start = Clock::now(); auto start = Clock::now();
auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...); auto&& r = Detail::complete_invoke(fun, CATCH_FORWARD(args)...);
auto end = Clock::now(); auto end = Clock::now();
auto delta = end - start; auto delta = end - start;
return { delta, std::forward<decltype(r)>(r), 1 }; return { delta, CATCH_FORWARD(r), 1 };
} }
} // namespace Detail } // namespace Detail
} // namespace Benchmark } // namespace Benchmark

View File

@ -11,7 +11,7 @@
#define CATCH_REPEAT_HPP_INCLUDED #define CATCH_REPEAT_HPP_INCLUDED
#include <type_traits> #include <type_traits>
#include <utility> #include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
namespace Benchmark { namespace Benchmark {
@ -27,7 +27,7 @@ namespace Catch {
}; };
template <typename Fun> template <typename Fun>
repeater<typename std::decay<Fun>::type> repeat(Fun&& fun) { repeater<typename std::decay<Fun>::type> repeat(Fun&& fun) {
return { std::forward<Fun>(fun) }; return { CATCH_FORWARD(fun) };
} }
} // namespace Detail } // namespace Detail
} // namespace Benchmark } // namespace Benchmark

View File

@ -16,8 +16,8 @@
#include <catch2/benchmark/detail/catch_complete_invoke.hpp> #include <catch2/benchmark/detail/catch_complete_invoke.hpp>
#include <catch2/benchmark/detail/catch_timing.hpp> #include <catch2/benchmark/detail/catch_timing.hpp>
#include <catch2/internal/catch_meta.hpp> #include <catch2/internal/catch_meta.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <utility>
#include <type_traits> #include <type_traits>
namespace Catch { namespace Catch {
@ -32,7 +32,7 @@ namespace Catch {
Detail::ChronometerModel<Clock> meter; Detail::ChronometerModel<Clock> meter;
auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters));
return { meter.elapsed(), std::move(result), iters }; return { meter.elapsed(), CATCH_MOVE(result), iters };
} }
template <typename Clock, typename Fun> template <typename Clock, typename Fun>
@ -52,7 +52,7 @@ namespace Catch {
auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>()); auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>());
if (Timing.elapsed >= how_long) { if (Timing.elapsed >= how_long) {
return { Timing.elapsed, std::move(Timing.result), iters }; return { Timing.elapsed, CATCH_MOVE(Timing.result), iters };
} }
iters *= 2; iters *= 2;
} }

View File

@ -9,6 +9,7 @@
#include <catch2/interfaces/catch_interfaces_capture.hpp> #include <catch2/interfaces/catch_interfaces_capture.hpp>
#include <catch2/internal/catch_uncaught_exceptions.hpp> #include <catch2/internal/catch_uncaught_exceptions.hpp>
#include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <cassert> #include <cassert>
#include <stack> #include <stack>
@ -25,7 +26,7 @@ namespace Catch {
} }
ScopedMessage::ScopedMessage( ScopedMessage&& old ) noexcept: ScopedMessage::ScopedMessage( ScopedMessage&& old ) noexcept:
m_info( std::move( old.m_info ) ) { m_info( CATCH_MOVE( old.m_info ) ) {
old.m_moved = true; old.m_moved = true;
} }

View File

@ -19,6 +19,7 @@
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <catch2/internal/catch_noncopyable.hpp> #include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp> #include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
@ -48,16 +49,16 @@ namespace Catch {
public: // IMutableRegistryHub public: // IMutableRegistryHub
void registerReporter( std::string const& name, IReporterFactoryPtr factory ) override { void registerReporter( std::string const& name, IReporterFactoryPtr factory ) override {
m_reporterRegistry.registerReporter( name, std::move(factory) ); m_reporterRegistry.registerReporter( name, CATCH_MOVE(factory) );
} }
void registerListener( IReporterFactoryPtr factory ) override { void registerListener( IReporterFactoryPtr factory ) override {
m_reporterRegistry.registerListener( std::move(factory) ); m_reporterRegistry.registerListener( CATCH_MOVE(factory) );
} }
void registerTest( Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker ) override { void registerTest( Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker ) override {
m_testCaseRegistry.registerTest( std::move(testInfo), std::move(invoker) ); m_testCaseRegistry.registerTest( CATCH_MOVE(testInfo), CATCH_MOVE(invoker) );
} }
void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) override { void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) override {
m_exceptionTranslatorRegistry.registerTranslator( std::move(translator) ); m_exceptionTranslatorRegistry.registerTranslator( CATCH_MOVE(translator) );
} }
void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override { void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override {
m_tagAliasRegistry.add( alias, tag, lineInfo ); m_tagAliasRegistry.add( alias, tag, lineInfo );

View File

@ -23,7 +23,7 @@ namespace Catch {
// still use the `-c` flag comfortably. // still use the `-c` flag comfortably.
SectionInfo( SourceLineInfo const& _lineInfo, std::string _name, SectionInfo( SourceLineInfo const& _lineInfo, std::string _name,
const char* const = nullptr ): const char* const = nullptr ):
name(std::move(_name)), name(CATCH_MOVE(_name)),
lineInfo(_lineInfo) lineInfo(_lineInfo)
{} {}

View File

@ -21,6 +21,7 @@
#include <catch2/reporters/catch_reporter_listening.hpp> #include <catch2/reporters/catch_reporter_listening.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_registry.hpp> #include <catch2/interfaces/catch_interfaces_reporter_registry.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp> #include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <algorithm> #include <algorithm>
#include <iomanip> #include <iomanip>
@ -57,7 +58,7 @@ namespace Catch {
explicit TestGroup(IStreamingReporterPtr&& reporter, Config const* config): explicit TestGroup(IStreamingReporterPtr&& reporter, Config const* config):
m_reporter(reporter.get()), m_reporter(reporter.get()),
m_config{config}, m_config{config},
m_context{config, std::move(reporter)} { m_context{config, CATCH_MOVE(reporter)} {
auto const& allTestCases = getAllTestCasesSorted(*m_config); auto const& allTestCases = getAllTestCasesSorted(*m_config);
m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config); m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config);
@ -277,7 +278,7 @@ namespace Catch {
return 0; return 0;
} }
TestGroup tests { std::move(reporter), m_config.get() }; TestGroup tests { CATCH_MOVE(reporter), m_config.get() };
auto const totals = tests.execute(); auto const totals = tests.execute();
if( m_config->warnAboutNoTests() && totals.error == -1 ) if( m_config->warnAboutNoTests() && totals.error == -1 )

View File

@ -11,6 +11,7 @@
#include <catch2/interfaces/catch_interfaces_generatortracker.hpp> #include <catch2/interfaces/catch_interfaces_generatortracker.hpp>
#include <catch2/internal/catch_source_line_info.hpp> #include <catch2/internal/catch_source_line_info.hpp>
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <vector> #include <vector>
#include <tuple> #include <tuple>
@ -55,7 +56,7 @@ namespace Detail {
GeneratorWrapper(IGenerator<T>* generator): GeneratorWrapper(IGenerator<T>* generator):
m_generator(generator) {} m_generator(generator) {}
GeneratorWrapper(GeneratorPtr<T> generator): GeneratorWrapper(GeneratorPtr<T> generator):
m_generator(std::move(generator)) {} m_generator(CATCH_MOVE(generator)) {}
T const& get() const { T const& get() const {
return m_generator->get(); return m_generator->get();
@ -74,7 +75,7 @@ namespace Detail {
m_value(value) m_value(value)
{} {}
SingleValueGenerator(T&& value): SingleValueGenerator(T&& value):
m_value(std::move(value)) m_value(CATCH_MOVE(value))
{} {}
T const& get() const override { T const& get() const override {
@ -108,7 +109,7 @@ namespace Detail {
GeneratorWrapper<DecayedT> value( T&& value ) { GeneratorWrapper<DecayedT> value( T&& value ) {
return GeneratorWrapper<DecayedT>( return GeneratorWrapper<DecayedT>(
Catch::Detail::make_unique<SingleValueGenerator<DecayedT>>( Catch::Detail::make_unique<SingleValueGenerator<DecayedT>>(
std::forward<T>( value ) ) ); CATCH_FORWARD( value ) ) );
} }
template <typename T> template <typename T>
GeneratorWrapper<T> values(std::initializer_list<T> values) { GeneratorWrapper<T> values(std::initializer_list<T> values) {
@ -121,35 +122,35 @@ namespace Detail {
size_t m_current = 0; size_t m_current = 0;
void add_generator( GeneratorWrapper<T>&& generator ) { void add_generator( GeneratorWrapper<T>&& generator ) {
m_generators.emplace_back( std::move( generator ) ); m_generators.emplace_back( CATCH_MOVE( generator ) );
} }
void add_generator( T const& val ) { void add_generator( T const& val ) {
m_generators.emplace_back( value( val ) ); m_generators.emplace_back( value( val ) );
} }
void add_generator( T&& val ) { void add_generator( T&& val ) {
m_generators.emplace_back( value( std::move( val ) ) ); m_generators.emplace_back( value( CATCH_MOVE( val ) ) );
} }
template <typename U> template <typename U>
std::enable_if_t<!std::is_same<std::decay_t<U>, T>::value> std::enable_if_t<!std::is_same<std::decay_t<U>, T>::value>
add_generator( U&& val ) { add_generator( U&& val ) {
add_generator( T( std::forward<U>( val ) ) ); add_generator( T( CATCH_FORWARD( val ) ) );
} }
template <typename U> void add_generators( U&& valueOrGenerator ) { template <typename U> void add_generators( U&& valueOrGenerator ) {
add_generator( std::forward<U>( valueOrGenerator ) ); add_generator( CATCH_FORWARD( valueOrGenerator ) );
} }
template <typename U, typename... Gs> template <typename U, typename... Gs>
void add_generators( U&& valueOrGenerator, Gs&&... moreGenerators ) { void add_generators( U&& valueOrGenerator, Gs&&... moreGenerators ) {
add_generator( std::forward<U>( valueOrGenerator ) ); add_generator( CATCH_FORWARD( valueOrGenerator ) );
add_generators( std::forward<Gs>( moreGenerators )... ); add_generators( CATCH_FORWARD( moreGenerators )... );
} }
public: public:
template <typename... Gs> template <typename... Gs>
Generators(Gs &&... moreGenerators) { Generators(Gs &&... moreGenerators) {
m_generators.reserve(sizeof...(Gs)); m_generators.reserve(sizeof...(Gs));
add_generators(std::forward<Gs>(moreGenerators)...); add_generators(CATCH_FORWARD(moreGenerators)...);
} }
T const& get() const override { T const& get() const override {
@ -181,19 +182,19 @@ namespace Detail {
template<typename T, typename... Gs> 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)...); return Generators<T>(CATCH_MOVE(generator), CATCH_FORWARD(moreGenerators)...);
} }
template<typename T> template<typename T>
auto makeGenerators( GeneratorWrapper<T>&& generator ) -> Generators<T> { auto makeGenerators( GeneratorWrapper<T>&& generator ) -> Generators<T> {
return Generators<T>(std::move(generator)); return Generators<T>(CATCH_MOVE(generator));
} }
template<typename T, typename... Gs> template<typename T, typename... Gs>
auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<std::decay_t<T>> { auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<std::decay_t<T>> {
return makeGenerators( value( std::forward<T>( val ) ), std::forward<Gs>( moreGenerators )... ); return makeGenerators( value( CATCH_FORWARD( val ) ), CATCH_FORWARD( moreGenerators )... );
} }
template<typename T, typename U, typename... Gs> 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 )... ); return makeGenerators( value( T( CATCH_FORWARD( val ) ) ), CATCH_FORWARD( moreGenerators )... );
} }
auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&;

View File

@ -10,6 +10,9 @@
#include <catch2/generators/catch_generators.hpp> #include <catch2/generators/catch_generators.hpp>
#include <catch2/internal/catch_meta.hpp> #include <catch2/internal/catch_meta.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <cassert>
namespace Catch { namespace Catch {
namespace Generators { namespace Generators {
@ -21,7 +24,7 @@ namespace Generators {
size_t m_target; size_t m_target;
public: public:
TakeGenerator(size_t target, GeneratorWrapper<T>&& generator): TakeGenerator(size_t target, GeneratorWrapper<T>&& generator):
m_generator(std::move(generator)), m_generator(CATCH_MOVE(generator)),
m_target(target) m_target(target)
{ {
assert(target != 0 && "Empty generators are not allowed"); assert(target != 0 && "Empty generators are not allowed");
@ -47,7 +50,7 @@ namespace Generators {
template <typename T> template <typename T>
GeneratorWrapper<T> take(size_t target, GeneratorWrapper<T>&& generator) { GeneratorWrapper<T> take(size_t target, GeneratorWrapper<T>&& generator) {
return GeneratorWrapper<T>(Catch::Detail::make_unique<TakeGenerator<T>>(target, std::move(generator))); return GeneratorWrapper<T>(Catch::Detail::make_unique<TakeGenerator<T>>(target, CATCH_MOVE(generator)));
} }
@ -58,8 +61,8 @@ namespace Generators {
public: public:
template <typename P = Predicate> template <typename P = Predicate>
FilterGenerator(P&& pred, GeneratorWrapper<T>&& generator): FilterGenerator(P&& pred, GeneratorWrapper<T>&& generator):
m_generator(std::move(generator)), m_generator(CATCH_MOVE(generator)),
m_predicate(std::forward<P>(pred)) m_predicate(CATCH_FORWARD(pred))
{ {
if (!m_predicate(m_generator.get())) { if (!m_predicate(m_generator.get())) {
// It might happen that there are no values that pass the // It might happen that there are no values that pass the
@ -88,7 +91,7 @@ namespace Generators {
template <typename T, typename Predicate> template <typename T, typename Predicate>
GeneratorWrapper<T> filter(Predicate&& pred, GeneratorWrapper<T>&& generator) { GeneratorWrapper<T> filter(Predicate&& pred, GeneratorWrapper<T>&& generator) {
return GeneratorWrapper<T>(Catch::Detail::make_unique<FilterGenerator<T, Predicate>>(std::forward<Predicate>(pred), std::move(generator))); return GeneratorWrapper<T>(Catch::Detail::make_unique<FilterGenerator<T, Predicate>>(CATCH_FORWARD(pred), CATCH_MOVE(generator)));
} }
template <typename T> template <typename T>
@ -103,7 +106,7 @@ namespace Generators {
size_t m_repeat_index = 0; size_t m_repeat_index = 0;
public: public:
RepeatGenerator(size_t repeats, GeneratorWrapper<T>&& generator): RepeatGenerator(size_t repeats, GeneratorWrapper<T>&& generator):
m_generator(std::move(generator)), m_generator(CATCH_MOVE(generator)),
m_target_repeats(repeats) m_target_repeats(repeats)
{ {
assert(m_target_repeats > 0 && "Repeat generator must repeat at least once"); assert(m_target_repeats > 0 && "Repeat generator must repeat at least once");
@ -144,7 +147,7 @@ namespace Generators {
template <typename T> template <typename T>
GeneratorWrapper<T> repeat(size_t repeats, GeneratorWrapper<T>&& generator) { GeneratorWrapper<T> repeat(size_t repeats, GeneratorWrapper<T>&& generator) {
return GeneratorWrapper<T>(Catch::Detail::make_unique<RepeatGenerator<T>>(repeats, std::move(generator))); return GeneratorWrapper<T>(Catch::Detail::make_unique<RepeatGenerator<T>>(repeats, CATCH_MOVE(generator)));
} }
template <typename T, typename U, typename Func> template <typename T, typename U, typename Func>
@ -157,8 +160,8 @@ namespace Generators {
public: public:
template <typename F2 = Func> template <typename F2 = Func>
MapGenerator(F2&& function, GeneratorWrapper<U>&& generator) : MapGenerator(F2&& function, GeneratorWrapper<U>&& generator) :
m_generator(std::move(generator)), m_generator(CATCH_MOVE(generator)),
m_function(std::forward<F2>(function)), m_function(CATCH_FORWARD(function)),
m_cache(m_function(m_generator.get())) m_cache(m_function(m_generator.get()))
{} {}
@ -177,14 +180,14 @@ namespace Generators {
template <typename Func, typename U, typename T = FunctionReturnType<Func, U>> template <typename Func, typename U, typename T = FunctionReturnType<Func, U>>
GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) { GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) {
return GeneratorWrapper<T>( return GeneratorWrapper<T>(
Catch::Detail::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator)) Catch::Detail::make_unique<MapGenerator<T, U, Func>>(CATCH_FORWARD(function), CATCH_MOVE(generator))
); );
} }
template <typename T, typename U, typename Func> template <typename T, typename U, typename Func>
GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) { GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) {
return GeneratorWrapper<T>( return GeneratorWrapper<T>(
Catch::Detail::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator)) Catch::Detail::make_unique<MapGenerator<T, U, Func>>(CATCH_FORWARD(function), CATCH_MOVE(generator))
); );
} }
@ -196,7 +199,7 @@ namespace Generators {
bool m_used_up = false; bool m_used_up = false;
public: public:
ChunkGenerator(size_t size, GeneratorWrapper<T> generator) : ChunkGenerator(size_t size, GeneratorWrapper<T> generator) :
m_chunk_size(size), m_generator(std::move(generator)) m_chunk_size(size), m_generator(CATCH_MOVE(generator))
{ {
m_chunk.reserve(m_chunk_size); m_chunk.reserve(m_chunk_size);
if (m_chunk_size != 0) { if (m_chunk_size != 0) {
@ -227,7 +230,7 @@ namespace Generators {
template <typename T> template <typename T>
GeneratorWrapper<std::vector<T>> chunk(size_t size, GeneratorWrapper<T>&& generator) { GeneratorWrapper<std::vector<T>> chunk(size_t size, GeneratorWrapper<T>&& generator) {
return GeneratorWrapper<std::vector<T>>( return GeneratorWrapper<std::vector<T>>(
Catch::Detail::make_unique<ChunkGenerator<T>>(size, std::move(generator)) Catch::Detail::make_unique<ChunkGenerator<T>>(size, CATCH_MOVE(generator))
); );
} }

View File

@ -14,7 +14,7 @@
#include <catch2/internal/catch_message_info.hpp> #include <catch2/internal/catch_message_info.hpp>
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
#include <catch2/internal/catch_unique_ptr.hpp> #include <catch2/internal/catch_unique_ptr.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/benchmark/catch_estimate.hpp> #include <catch2/benchmark/catch_estimate.hpp>
#include <catch2/benchmark/catch_outlier_classification.hpp> #include <catch2/benchmark/catch_outlier_classification.hpp>
@ -150,7 +150,7 @@ namespace Catch {
} }
return { return {
info, info,
std::move(samples2), CATCH_MOVE(samples2),
mean, mean,
standardDeviation, standardDeviation,
outliers, outliers,

View File

@ -30,11 +30,11 @@
#endif #endif
#include <catch2/internal/catch_noncopyable.hpp> #include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <cassert> #include <cassert>
#include <cctype> #include <cctype>
#include <memory> #include <memory>
#include <ostream>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
@ -293,7 +293,7 @@ namespace Catch {
T temp; T temp;
auto result = convertInto( source, temp ); auto result = convertInto( source, temp );
if ( result ) if ( result )
target = std::move( temp ); target = CATCH_MOVE( temp );
return result; return result;
} }
#endif // CLARA_CONFIG_OPTIONAL_TYPE #endif // CLARA_CONFIG_OPTIONAL_TYPE

View File

@ -9,6 +9,7 @@
#include <catch2/internal/catch_compiler_capabilities.hpp> #include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_test_failure_exception.hpp> #include <catch2/internal/catch_test_failure_exception.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
@ -16,7 +17,7 @@ namespace Catch {
} }
void ExceptionTranslatorRegistry::registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) { void ExceptionTranslatorRegistry::registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) {
m_translators.push_back( std::move( translator ) ); m_translators.push_back( CATCH_MOVE( translator ) );
} }
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)

View File

@ -12,6 +12,7 @@
#include <catch2/interfaces/catch_interfaces_reporter_registry.hpp> #include <catch2/interfaces/catch_interfaces_reporter_registry.hpp>
#include <catch2/interfaces/catch_interfaces_testcase.hpp> #include <catch2/interfaces/catch_interfaces_testcase.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp> #include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/internal/catch_context.hpp> #include <catch2/internal/catch_context.hpp>
#include <catch2/catch_config.hpp> #include <catch2/catch_config.hpp>
@ -43,7 +44,7 @@ namespace Catch {
std::vector<TagInfo> infos; infos.reserve(tagCounts.size()); std::vector<TagInfo> infos; infos.reserve(tagCounts.size());
for (auto& tagc : tagCounts) { for (auto& tagc : tagCounts) {
infos.push_back(std::move(tagc.second)); infos.push_back(CATCH_MOVE(tagc.second));
} }
reporter.listTags(infos); reporter.listTags(infos);

View File

@ -16,6 +16,7 @@
#include <catch2/reporters/catch_reporter_tap.hpp> #include <catch2/reporters/catch_reporter_tap.hpp>
#include <catch2/reporters/catch_reporter_teamcity.hpp> #include <catch2/reporters/catch_reporter_teamcity.hpp>
#include <catch2/reporters/catch_reporter_xml.hpp> #include <catch2/reporters/catch_reporter_xml.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
@ -43,10 +44,10 @@ namespace Catch {
} }
void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) { void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) {
m_factories.emplace(name, std::move(factory)); m_factories.emplace(name, CATCH_MOVE(factory));
} }
void ReporterRegistry::registerListener( IReporterFactoryPtr factory ) { void ReporterRegistry::registerListener( IReporterFactoryPtr factory ) {
m_listeners.push_back( std::move(factory) ); m_listeners.push_back( CATCH_MOVE(factory) );
} }
IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const { IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const {

View File

@ -64,7 +64,7 @@ namespace Catch {
Catch::Detail::make_unique<GeneratorTracker>( Catch::Detail::make_unique<GeneratorTracker>(
nameAndLocation, ctx, &currentTracker ); nameAndLocation, ctx, &currentTracker );
tracker = newTracker.get(); tracker = newTracker.get();
currentTracker.addChild( std::move(newTracker) ); currentTracker.addChild( CATCH_MOVE(newTracker) );
} }
if( !tracker->isComplete() ) { if( !tracker->isComplete() ) {
@ -153,7 +153,7 @@ namespace Catch {
return m_generator; return m_generator;
} }
void setGenerator( GeneratorBasePtr&& generator ) override { void setGenerator( GeneratorBasePtr&& generator ) override {
m_generator = std::move( generator ); m_generator = CATCH_MOVE( generator );
} }
}; };
GeneratorTracker::~GeneratorTracker() = default; GeneratorTracker::~GeneratorTracker() = default;
@ -163,7 +163,7 @@ namespace Catch {
: m_runInfo(_config->name()), : m_runInfo(_config->name()),
m_context(getCurrentMutableContext()), m_context(getCurrentMutableContext()),
m_config(_config), m_config(_config),
m_reporter(std::move(reporter)), m_reporter(CATCH_MOVE(reporter)),
m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal },
m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions )
{ {

View File

@ -18,6 +18,7 @@
#include <catch2/catch_assertion_info.hpp> #include <catch2/catch_assertion_info.hpp>
#include <catch2/catch_assertion_result.hpp> #include <catch2/catch_assertion_result.hpp>
#include <catch2/internal/catch_option.hpp> #include <catch2/internal/catch_option.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <string> #include <string>

View File

@ -6,15 +6,16 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/internal/catch_section.hpp> #include <catch2/internal/catch_section.hpp>
#include <catch2/internal/catch_test_macro_impl.hpp> #include <catch2/internal/catch_run_context.hpp>
#include <catch2/internal/catch_uncaught_exceptions.hpp> #include <catch2/internal/catch_uncaught_exceptions.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <utility> #include <utility>
namespace Catch { namespace Catch {
Section::Section( SectionInfo&& info ): Section::Section( SectionInfo&& info ):
m_info( std::move( info ) ), m_info( CATCH_MOVE( info ) ),
m_sectionIncluded( m_sectionIncluded(
getResultCapture().sectionStarted( m_info, m_assertions ) ) { getResultCapture().sectionStarted( m_info, m_assertions ) ) {
// Non-"included" sections will not use the timing information // Non-"included" sections will not use the timing information

View File

@ -14,6 +14,7 @@
#include <catch2/internal/catch_run_context.hpp> #include <catch2/internal/catch_run_context.hpp>
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <catch2/catch_test_spec.hpp> #include <catch2/catch_test_spec.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <algorithm> #include <algorithm>
#include <set> #include <set>
@ -119,8 +120,8 @@ namespace {
void TestRegistry::registerTest(Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker) { void TestRegistry::registerTest(Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker) {
m_handles.emplace_back(testInfo.get(), testInvoker.get()); m_handles.emplace_back(testInfo.get(), testInvoker.get());
m_viewed_test_infos.push_back(testInfo.get()); m_viewed_test_infos.push_back(testInfo.get());
m_owned_test_infos.push_back(std::move(testInfo)); m_owned_test_infos.push_back(CATCH_MOVE(testInfo));
m_invokers.push_back(std::move(testInvoker)); m_invokers.push_back(CATCH_MOVE(testInvoker));
} }
std::vector<TestCaseInfo*> const& TestRegistry::getAllInfos() const { std::vector<TestCaseInfo*> const& TestRegistry::getAllInfos() const {

View File

@ -9,6 +9,7 @@
#include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -34,7 +35,7 @@ namespace TestCaseTracking {
} }
void ITracker::addChild( ITrackerPtr&& child ) { void ITracker::addChild( ITrackerPtr&& child ) {
m_children.push_back( std::move(child) ); m_children.push_back( CATCH_MOVE(child) );
} }
ITracker* ITracker::findChild( NameAndLocation const& nameAndLocation ) { ITracker* ITracker::findChild( NameAndLocation const& nameAndLocation ) {
@ -207,7 +208,7 @@ namespace TestCaseTracking {
auto newSection = Catch::Detail::make_unique<SectionTracker>( auto newSection = Catch::Detail::make_unique<SectionTracker>(
nameAndLocation, ctx, &currentTracker ); nameAndLocation, ctx, &currentTracker );
section = newSection.get(); section = newSection.get();
currentTracker.addChild( std::move( newSection ) ); currentTracker.addChild( CATCH_MOVE( newSection ) );
} }
if( !ctx.completedCycle() ) if( !ctx.completedCycle() )
section->tryOpen(); section->tryOpen();

View File

@ -11,6 +11,7 @@
#include <catch2/internal/catch_test_case_registry_impl.hpp> #include <catch2/internal/catch_test_case_registry_impl.hpp>
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp> #include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
@ -42,7 +43,7 @@ namespace Catch {
extractClassName( classOrMethod ), extractClassName( classOrMethod ),
nameAndTags, nameAndTags,
lineInfo), lineInfo),
std::move(invoker) CATCH_MOVE(invoker)
); );
} CATCH_CATCH_ALL { } CATCH_CATCH_ALL {
// Do not throw when constructing global objects, instead register the exception to be processed later // Do not throw when constructing global objects, instead register the exception to be processed later

View File

@ -9,6 +9,7 @@
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp> #include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
@ -35,7 +36,7 @@ namespace Catch {
} }
TestSpec TestSpecParser::testSpec() { TestSpec TestSpecParser::testSpec() {
addFilter(); addFilter();
return std::move(m_testSpec); return CATCH_MOVE(m_testSpec);
} }
bool TestSpecParser::visitChar( char c ) { bool TestSpecParser::visitChar( char c ) {
if( (m_mode != EscapedName) && (c == '\\') ) { if( (m_mode != EscapedName) && (c == '\\') ) {
@ -151,7 +152,7 @@ namespace Catch {
void TestSpecParser::addFilter() { void TestSpecParser::addFilter() {
if( !m_currentFilter.m_required.empty() || !m_currentFilter.m_forbidden.empty() ) { if( !m_currentFilter.m_required.empty() || !m_currentFilter.m_forbidden.empty() ) {
m_testSpec.m_filters.push_back( std::move(m_currentFilter) ); m_testSpec.m_filters.push_back( CATCH_MOVE(m_currentFilter) );
m_currentFilter = TestSpec::Filter(); m_currentFilter = TestSpec::Filter();
} }
} }

View File

@ -9,6 +9,7 @@
#define CATCH_MATCHERS_HPP_INCLUDED #define CATCH_MATCHERS_HPP_INCLUDED
#include <catch2/matchers/internal/catch_matchers_impl.hpp> #include <catch2/matchers/internal/catch_matchers_impl.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
@ -87,11 +88,11 @@ namespace Matchers {
friend MatchAllOf operator&& (MatchAllOf&& lhs, MatcherBase<ArgT> const& rhs) { friend MatchAllOf operator&& (MatchAllOf&& lhs, MatcherBase<ArgT> const& rhs) {
lhs.m_matchers.push_back(&rhs); lhs.m_matchers.push_back(&rhs);
return std::move(lhs); return CATCH_MOVE(lhs);
} }
friend MatchAllOf operator&& (MatcherBase<ArgT> const& lhs, MatchAllOf&& rhs) { friend MatchAllOf operator&& (MatcherBase<ArgT> const& lhs, MatchAllOf&& rhs) {
rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs); rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
return std::move(rhs); return CATCH_MOVE(rhs);
} }
private: private:
@ -140,11 +141,11 @@ namespace Matchers {
friend MatchAnyOf operator|| (MatchAnyOf&& lhs, MatcherBase<ArgT> const& rhs) { friend MatchAnyOf operator|| (MatchAnyOf&& lhs, MatcherBase<ArgT> const& rhs) {
lhs.m_matchers.push_back(&rhs); lhs.m_matchers.push_back(&rhs);
return std::move(lhs); return CATCH_MOVE(lhs);
} }
friend MatchAnyOf operator|| (MatcherBase<ArgT> const& lhs, MatchAnyOf&& rhs) { friend MatchAnyOf operator|| (MatcherBase<ArgT> const& lhs, MatchAnyOf&& rhs) {
rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs); rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
return std::move(rhs); return CATCH_MOVE(rhs);
} }
private: private:

View File

@ -10,6 +10,7 @@
#include <catch2/matchers/catch_matchers_templated.hpp> #include <catch2/matchers/catch_matchers_templated.hpp>
#include <catch2/internal/catch_container_nonmembers.hpp> #include <catch2/internal/catch_container_nonmembers.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
namespace Matchers { namespace Matchers {
@ -55,7 +56,7 @@ namespace Catch {
Matcher m_matcher; Matcher m_matcher;
public: public:
explicit SizeMatchesMatcher(Matcher m): explicit SizeMatchesMatcher(Matcher m):
m_matcher(std::move(m)) m_matcher(CATCH_MOVE(m))
{} {}
template <typename RangeLike> template <typename RangeLike>
@ -81,7 +82,7 @@ namespace Catch {
template <typename Matcher> template <typename Matcher>
std::enable_if_t<Detail::is_matcher<Matcher>::value, std::enable_if_t<Detail::is_matcher<Matcher>::value,
SizeMatchesMatcher<Matcher>> SizeIs(Matcher&& m) { SizeMatchesMatcher<Matcher>> SizeIs(Matcher&& m) {
return SizeMatchesMatcher<Matcher>{std::forward<Matcher>(m)}; return SizeMatchesMatcher<Matcher>{CATCH_FORWARD(m)};
} }
} // end namespace Matchers } // end namespace Matchers

View File

@ -9,6 +9,7 @@
#define CATCH_MATCHERS_CONTAINS_HPP_INCLUDED #define CATCH_MATCHERS_CONTAINS_HPP_INCLUDED
#include <catch2/matchers/catch_matchers_templated.hpp> #include <catch2/matchers/catch_matchers_templated.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
@ -24,8 +25,8 @@ namespace Catch {
public: public:
template <typename T2, typename Equality2> template <typename T2, typename Equality2>
ContainsElementMatcher(T2&& target, Equality2&& predicate): ContainsElementMatcher(T2&& target, Equality2&& predicate):
m_desired(std::forward<T2>(target)), m_desired(CATCH_FORWARD(target)),
m_eq(std::forward<Equality2>(predicate)) m_eq(CATCH_FORWARD(predicate))
{} {}
std::string describe() const override { std::string describe() const override {
@ -52,7 +53,7 @@ namespace Catch {
// constructor (and also avoid some perfect forwarding failure // constructor (and also avoid some perfect forwarding failure
// cases) // cases)
ContainsMatcherMatcher(Matcher matcher): ContainsMatcherMatcher(Matcher matcher):
m_matcher(std::move(matcher)) m_matcher(CATCH_MOVE(matcher))
{} {}
template <typename RangeLike> template <typename RangeLike>
@ -78,14 +79,14 @@ namespace Catch {
template <typename T> template <typename T>
std::enable_if_t<!Detail::is_matcher<T>::value, std::enable_if_t<!Detail::is_matcher<T>::value,
ContainsElementMatcher<T, std::equal_to<>>> Contains(T&& elem) { ContainsElementMatcher<T, std::equal_to<>>> Contains(T&& elem) {
return { std::forward<T>(elem), std::equal_to<>{} }; return { CATCH_FORWARD(elem), std::equal_to<>{} };
} }
//! Creates a matcher that checks whether a range contains element matching a matcher //! Creates a matcher that checks whether a range contains element matching a matcher
template <typename Matcher> template <typename Matcher>
std::enable_if_t<Detail::is_matcher<Matcher>::value, std::enable_if_t<Detail::is_matcher<Matcher>::value,
ContainsMatcherMatcher<Matcher>> Contains(Matcher&& matcher) { ContainsMatcherMatcher<Matcher>> Contains(Matcher&& matcher) {
return { std::forward<Matcher>(matcher) }; return { CATCH_FORWARD(matcher) };
} }
/** /**
@ -95,7 +96,7 @@ namespace Catch {
*/ */
template <typename T, typename Equality> template <typename T, typename Equality>
ContainsElementMatcher<T, Equality> Contains(T&& elem, Equality&& eq) { ContainsElementMatcher<T, Equality> Contains(T&& elem, Equality&& eq) {
return { std::forward<T>(elem), std::forward<Equality>(eq) }; return { CATCH_FORWARD(elem), CATCH_FORWARD(eq) };
} }
} }

View File

@ -10,9 +10,9 @@
#include <catch2/matchers/catch_matchers.hpp> #include <catch2/matchers/catch_matchers.hpp>
#include <catch2/internal/catch_meta.hpp> #include <catch2/internal/catch_meta.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <string> #include <string>
#include <utility>
namespace Catch { namespace Catch {
namespace Matchers { namespace Matchers {
@ -28,7 +28,7 @@ class PredicateMatcher final : public MatcherBase<T> {
public: public:
PredicateMatcher(Predicate&& elem, std::string const& descr) PredicateMatcher(Predicate&& elem, std::string const& descr)
:m_predicate(std::forward<Predicate>(elem)), :m_predicate(CATCH_FORWARD(elem)),
m_description(Detail::finalizeDescription(descr)) m_description(Detail::finalizeDescription(descr))
{} {}
@ -50,7 +50,7 @@ public:
PredicateMatcher<T, Pred> Predicate(Pred&& predicate, std::string const& description = "") { PredicateMatcher<T, Pred> Predicate(Pred&& predicate, std::string const& description = "") {
static_assert(is_callable<Pred(T)>::value, "Predicate not callable with argument T"); static_assert(is_callable<Pred(T)>::value, "Predicate not callable with argument T");
static_assert(std::is_same<bool, FunctionReturnType<Pred, T>>::value, "Predicate does not return bool"); static_assert(std::is_same<bool, FunctionReturnType<Pred, T>>::value, "Predicate does not return bool");
return PredicateMatcher<T, Pred>(std::forward<Pred>(predicate), description); return PredicateMatcher<T, Pred>(CATCH_FORWARD(predicate), description);
} }
} // namespace Matchers } // namespace Matchers

View File

@ -9,8 +9,7 @@
#define CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED #define CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED
#include <catch2/matchers/catch_matchers_templated.hpp> #include <catch2/matchers/catch_matchers_templated.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <utility>
namespace Catch { namespace Catch {
namespace Matchers { namespace Matchers {
@ -20,7 +19,7 @@ namespace Catch {
Matcher m_matcher; Matcher m_matcher;
public: public:
AllMatchMatcher(Matcher matcher): AllMatchMatcher(Matcher matcher):
m_matcher(std::move(matcher)) m_matcher(CATCH_MOVE(matcher))
{} {}
std::string describe() const override { std::string describe() const override {
@ -44,7 +43,7 @@ namespace Catch {
Matcher m_matcher; Matcher m_matcher;
public: public:
NoneMatchMatcher(Matcher matcher): NoneMatchMatcher(Matcher matcher):
m_matcher(std::move(matcher)) m_matcher(CATCH_MOVE(matcher))
{} {}
std::string describe() const override { std::string describe() const override {
@ -68,7 +67,7 @@ namespace Catch {
Matcher m_matcher; Matcher m_matcher;
public: public:
AnyMatchMatcher(Matcher matcher): AnyMatchMatcher(Matcher matcher):
m_matcher(std::move(matcher)) m_matcher(CATCH_MOVE(matcher))
{} {}
std::string describe() const override { std::string describe() const override {
@ -89,19 +88,19 @@ namespace Catch {
// Creates a matcher that checks whether a range contains element matching a matcher // Creates a matcher that checks whether a range contains element matching a matcher
template <typename Matcher> template <typename Matcher>
AllMatchMatcher<Matcher> AllMatch(Matcher&& matcher) { AllMatchMatcher<Matcher> AllMatch(Matcher&& matcher) {
return { std::forward<Matcher>(matcher) }; return { CATCH_FORWARD(matcher) };
} }
// Creates a matcher that checks whether no element in a range matches a matcher. // Creates a matcher that checks whether no element in a range matches a matcher.
template <typename Matcher> template <typename Matcher>
NoneMatchMatcher<Matcher> NoneMatch(Matcher&& matcher) { NoneMatchMatcher<Matcher> NoneMatch(Matcher&& matcher) {
return { std::forward<Matcher>(matcher) }; return { CATCH_FORWARD(matcher) };
} }
// Creates a matcher that checks whether any element in a range matches a matcher. // Creates a matcher that checks whether any element in a range matches a matcher.
template <typename Matcher> template <typename Matcher>
AnyMatchMatcher<Matcher> AnyMatch(Matcher&& matcher) { AnyMatchMatcher<Matcher> AnyMatch(Matcher&& matcher) {
return { std::forward<Matcher>(matcher) }; return { CATCH_FORWARD(matcher) };
} }
} }
} }

View File

@ -8,6 +8,7 @@
#include <catch2/matchers/catch_matchers_string.hpp> #include <catch2/matchers/catch_matchers_string.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/catch_tostring.hpp> #include <catch2/catch_tostring.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <regex> #include <regex>
@ -76,7 +77,7 @@ namespace Matchers {
RegexMatcher::RegexMatcher(std::string regex, CaseSensitive caseSensitivity): m_regex(std::move(regex)), m_caseSensitivity(caseSensitivity) {} RegexMatcher::RegexMatcher(std::string regex, CaseSensitive caseSensitivity): m_regex(CATCH_MOVE(regex)), m_caseSensitivity(caseSensitivity) {}
bool RegexMatcher::match(std::string const& matchee) const { bool RegexMatcher::match(std::string const& matchee) const {
auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway

View File

@ -10,6 +10,7 @@
#include <catch2/matchers/catch_matchers.hpp> #include <catch2/matchers/catch_matchers.hpp>
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <array> #include <array>
#include <algorithm> #include <algorithm>
@ -145,7 +146,7 @@ namespace Matchers {
MatchAllOfGeneric<MatcherTs..., MatchersRHS...> operator && ( MatchAllOfGeneric<MatcherTs..., MatchersRHS...> operator && (
MatchAllOfGeneric<MatcherTs...>&& lhs, MatchAllOfGeneric<MatcherTs...>&& lhs,
MatchAllOfGeneric<MatchersRHS...>&& rhs) { MatchAllOfGeneric<MatchersRHS...>&& rhs) {
return MatchAllOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))}; return MatchAllOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(CATCH_MOVE(lhs.m_matchers), CATCH_MOVE(rhs.m_matchers))};
} }
//! Avoids type nesting for `GenericAllOf && some matcher` case //! Avoids type nesting for `GenericAllOf && some matcher` case
@ -154,7 +155,7 @@ namespace Matchers {
MatchAllOfGeneric<MatcherTs..., MatcherRHS>> operator && ( MatchAllOfGeneric<MatcherTs..., MatcherRHS>> operator && (
MatchAllOfGeneric<MatcherTs...>&& lhs, MatchAllOfGeneric<MatcherTs...>&& lhs,
MatcherRHS const& rhs) { MatcherRHS const& rhs) {
return MatchAllOfGeneric<MatcherTs..., MatcherRHS>{array_cat(std::move(lhs.m_matchers), static_cast<void const*>(&rhs))}; return MatchAllOfGeneric<MatcherTs..., MatcherRHS>{array_cat(CATCH_MOVE(lhs.m_matchers), static_cast<void const*>(&rhs))};
} }
//! Avoids type nesting for `some matcher && GenericAllOf` case //! Avoids type nesting for `some matcher && GenericAllOf` case
@ -163,7 +164,7 @@ namespace Matchers {
MatchAllOfGeneric<MatcherLHS, MatcherTs...>> operator && ( MatchAllOfGeneric<MatcherLHS, MatcherTs...>> operator && (
MatcherLHS const& lhs, MatcherLHS const& lhs,
MatchAllOfGeneric<MatcherTs...>&& rhs) { MatchAllOfGeneric<MatcherTs...>&& rhs) {
return MatchAllOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const*>(std::addressof(lhs)), std::move(rhs.m_matchers))}; return MatchAllOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const*>(std::addressof(lhs)), CATCH_MOVE(rhs.m_matchers))};
} }
}; };
@ -194,7 +195,7 @@ namespace Matchers {
friend MatchAnyOfGeneric<MatcherTs..., MatchersRHS...> operator || ( friend MatchAnyOfGeneric<MatcherTs..., MatchersRHS...> operator || (
MatchAnyOfGeneric<MatcherTs...>&& lhs, MatchAnyOfGeneric<MatcherTs...>&& lhs,
MatchAnyOfGeneric<MatchersRHS...>&& rhs) { MatchAnyOfGeneric<MatchersRHS...>&& rhs) {
return MatchAnyOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))}; return MatchAnyOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(CATCH_MOVE(lhs.m_matchers), CATCH_MOVE(rhs.m_matchers))};
} }
//! Avoids type nesting for `GenericAnyOf || some matcher` case //! Avoids type nesting for `GenericAnyOf || some matcher` case
@ -203,7 +204,7 @@ namespace Matchers {
MatchAnyOfGeneric<MatcherTs..., MatcherRHS>> operator || ( MatchAnyOfGeneric<MatcherTs..., MatcherRHS>> operator || (
MatchAnyOfGeneric<MatcherTs...>&& lhs, MatchAnyOfGeneric<MatcherTs...>&& lhs,
MatcherRHS const& rhs) { MatcherRHS const& rhs) {
return MatchAnyOfGeneric<MatcherTs..., MatcherRHS>{array_cat(std::move(lhs.m_matchers), static_cast<void const*>(std::addressof(rhs)))}; return MatchAnyOfGeneric<MatcherTs..., MatcherRHS>{array_cat(CATCH_MOVE(lhs.m_matchers), static_cast<void const*>(std::addressof(rhs)))};
} }
//! Avoids type nesting for `some matcher || GenericAnyOf` case //! Avoids type nesting for `some matcher || GenericAnyOf` case
@ -212,7 +213,7 @@ namespace Matchers {
MatchAnyOfGeneric<MatcherLHS, MatcherTs...>> operator || ( MatchAnyOfGeneric<MatcherLHS, MatcherTs...>> operator || (
MatcherLHS const& lhs, MatcherLHS const& lhs,
MatchAnyOfGeneric<MatcherTs...>&& rhs) { MatchAnyOfGeneric<MatcherTs...>&& rhs) {
return MatchAnyOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const*>(std::addressof(lhs)), std::move(rhs.m_matchers))}; return MatchAnyOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const*>(std::addressof(lhs)), CATCH_MOVE(rhs.m_matchers))};
} }
}; };

View File

@ -23,6 +23,7 @@
#include <catch2/matchers/internal/catch_matchers_impl.hpp> #include <catch2/matchers/internal/catch_matchers_impl.hpp>
#include <catch2/matchers/catch_matchers.hpp> #include <catch2/matchers/catch_matchers.hpp>
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp> #include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
@ -31,7 +32,7 @@ namespace Catch {
// the Equals matcher (so the header does not mention matchers) // the Equals matcher (so the header does not mention matchers)
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) { void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) {
std::string exceptionMessage = Catch::translateActiveException(); std::string exceptionMessage = Catch::translateActiveException();
MatchExpr<std::string, StringMatcher const&> expr( std::move(exceptionMessage), matcher, matcherString ); MatchExpr<std::string, StringMatcher const&> expr( CATCH_MOVE(exceptionMessage), matcher, matcherString );
handler.handleExpr( expr ); handler.handleExpr( expr );
} }

View File

@ -10,6 +10,7 @@
#include <catch2/internal/catch_test_macro_impl.hpp> #include <catch2/internal/catch_test_macro_impl.hpp>
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
namespace Catch { namespace Catch {
@ -21,7 +22,7 @@ namespace Catch {
public: public:
MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString )
: ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose : ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose
m_arg( std::forward<ArgT>(arg) ), m_arg( CATCH_FORWARD(arg) ),
m_matcher( matcher ), m_matcher( matcher ),
m_matcherString( matcherString ) m_matcherString( matcherString )
{} {}
@ -44,7 +45,7 @@ namespace Catch {
template<typename ArgT, typename MatcherT> template<typename ArgT, typename MatcherT>
auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> { auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> {
return MatchExpr<ArgT, MatcherT>( std::forward<ArgT>(arg), matcher, matcherString ); return MatchExpr<ArgT, MatcherT>( CATCH_FORWARD(arg), matcher, matcherString );
} }
} // namespace Catch } // namespace Catch

View File

@ -18,8 +18,8 @@
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <catch2/internal/catch_console_width.hpp> #include <catch2/internal/catch_console_width.hpp>
#include <catch2/reporters/catch_reporter_helpers.hpp> #include <catch2/reporters/catch_reporter_helpers.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <cfloat>
#include <cstdio> #include <cstdio>
#if defined(_MSC_VER) #if defined(_MSC_VER)
@ -285,7 +285,7 @@ class TablePrinter {
public: public:
TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos ) TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos )
: m_os( os ), : m_os( os ),
m_columnInfos( std::move( columnInfos ) ) {} m_columnInfos( CATCH_MOVE( columnInfos ) ) {}
auto columnInfos() const -> std::vector<ColumnInfo> const& { auto columnInfos() const -> std::vector<ColumnInfo> const& {
return m_columnInfos; return m_columnInfos;
@ -592,7 +592,7 @@ void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t
struct SummaryColumn { struct SummaryColumn {
SummaryColumn( std::string _label, Colour::Code _colour ) SummaryColumn( std::string _label, Colour::Code _colour )
: label( std::move( _label ) ), : label( CATCH_MOVE( _label ) ),
colour( _colour ) {} colour( _colour ) {}
SummaryColumn addRow( std::size_t count ) { SummaryColumn addRow( std::size_t count ) {
ReusableStringStream rss; ReusableStringStream rss;

View File

@ -54,7 +54,7 @@ namespace Catch {
auto newNode = auto newNode =
Detail::make_unique<SectionNode>( incompleteStats ); Detail::make_unique<SectionNode>( incompleteStats );
node = newNode.get(); node = newNode.get();
parentNode.childSections.push_back( std::move( newNode ) ); parentNode.childSections.push_back( CATCH_MOVE( newNode ) );
} else { } else {
node = it->get(); node = it->get();
} }
@ -90,8 +90,8 @@ namespace Catch {
TestCaseStats const& testCaseStats ) { TestCaseStats const& testCaseStats ) {
auto node = Detail::make_unique<TestCaseNode>( testCaseStats ); auto node = Detail::make_unique<TestCaseNode>( testCaseStats );
assert( m_sectionStack.size() == 0 ); assert( m_sectionStack.size() == 0 );
node->children.push_back( std::move(m_rootSection) ); node->children.push_back( CATCH_MOVE(m_rootSection) );
m_testCases.push_back( std::move(node) ); m_testCases.push_back( CATCH_MOVE(node) );
assert( m_deepestSection ); assert( m_deepestSection );
m_deepestSection->stdOut = testCaseStats.stdOut; m_deepestSection->stdOut = testCaseStats.stdOut;
@ -102,7 +102,7 @@ namespace Catch {
TestGroupStats const& testGroupStats ) { TestGroupStats const& testGroupStats ) {
auto node = Detail::make_unique<TestGroupNode>( testGroupStats ); auto node = Detail::make_unique<TestGroupNode>( testGroupStats );
node->children.swap( m_testCases ); node->children.swap( m_testCases );
m_testGroups.push_back( std::move(node) ); m_testGroups.push_back( CATCH_MOVE(node) );
} }
void CumulativeReporterBase::testRunEnded( TestRunStats const& testRunStats ) { void CumulativeReporterBase::testRunEnded( TestRunStats const& testRunStats ) {

View File

@ -6,18 +6,19 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/reporters/catch_reporter_listening.hpp> #include <catch2/reporters/catch_reporter_listening.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <cassert> #include <cassert>
namespace Catch { namespace Catch {
void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) { void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) {
m_listeners.push_back( std::move( listener ) ); m_listeners.push_back( CATCH_MOVE( listener ) );
} }
void ListeningReporter::addReporter(IStreamingReporterPtr&& reporter) { void ListeningReporter::addReporter(IStreamingReporterPtr&& reporter) {
assert(!m_reporter && "Listening reporter can wrap only 1 real reporter"); assert(!m_reporter && "Listening reporter can wrap only 1 real reporter");
m_reporter = std::move( reporter ); m_reporter = CATCH_MOVE( reporter );
m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut; m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut;
} }