Explicitly default smfs when relevant to avoid Wdeprecated-copy-dtor

This commit is contained in:
Martin Hořeňovský 2020-05-11 20:15:58 +02:00
parent 579dcd1a76
commit 03ef6b9f9a
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
9 changed files with 44 additions and 10 deletions

View File

@ -23,6 +23,10 @@ namespace Catch {
virtual void start() = 0; virtual void start() = 0;
virtual void finish() = 0; virtual void finish() = 0;
virtual ~ChronometerConcept(); // = default; virtual ~ChronometerConcept(); // = default;
ChronometerConcept() = default;
ChronometerConcept(ChronometerConcept const&) = default;
ChronometerConcept& operator=(ChronometerConcept const&) = default;
}; };
template <typename Clock> template <typename Clock>
struct ChronometerModel final : public ChronometerConcept { struct ChronometerModel final : public ChronometerConcept {

View File

@ -42,6 +42,10 @@ namespace Catch {
virtual void call(Chronometer meter) const = 0; virtual void call(Chronometer meter) const = 0;
virtual callable* clone() const = 0; virtual callable* clone() const = 0;
virtual ~callable(); // = default; virtual ~callable(); // = default;
callable() = default;
callable(callable const&) = default;
callable& operator=(callable const&) = default;
}; };
template <typename Fun> template <typename Fun>
struct model : public callable { struct model : public callable {

View File

@ -30,6 +30,10 @@ namespace Detail {
template<typename T> template<typename T>
struct IGenerator : GeneratorUntypedBase { struct IGenerator : GeneratorUntypedBase {
~IGenerator() override = default; ~IGenerator() override = default;
IGenerator() = default;
IGenerator(IGenerator const&) = default;
IGenerator& operator=(IGenerator const&) = default;
// Returns the current element of the generator // Returns the current element of the generator
// //

View File

@ -36,7 +36,7 @@ namespace Catch {
namespace Catch { namespace Catch {
IGeneratorTracker::~IGeneratorTracker() {} IGeneratorTracker::~IGeneratorTracker() = default;
namespace Generators { namespace Generators {
@ -48,7 +48,7 @@ namespace Detail {
} }
} // end namespace Detail } // end namespace Detail
GeneratorUntypedBase::~GeneratorUntypedBase() {} GeneratorUntypedBase::~GeneratorUntypedBase() = default;
auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& {
return getResultCapture().acquireGeneratorTracker( lineInfo ); return getResultCapture().acquireGeneratorTracker( lineInfo );

View File

@ -16,11 +16,17 @@ namespace Catch {
class GeneratorUntypedBase { class GeneratorUntypedBase {
public: public:
GeneratorUntypedBase() = default; GeneratorUntypedBase() = default;
virtual ~GeneratorUntypedBase(); // Generation of copy ops is deprecated (and Clang will complain)
// if there is a user destructor defined
GeneratorUntypedBase(GeneratorUntypedBase const&) = default;
GeneratorUntypedBase& operator=(GeneratorUntypedBase const&) = default;
virtual ~GeneratorUntypedBase(); // = default;
// Attempts to move the generator to the next element // Attempts to move the generator to the next element
// //
// Returns true iff the move succeeded (and a valid element // Returns true iff the move succeeded (and a valid element
// can be retrieved). // can be retrieved).
virtual bool next() = 0; virtual bool next() = 0;
}; };
using GeneratorBasePtr = std::unique_ptr<GeneratorUntypedBase>; using GeneratorBasePtr = std::unique_ptr<GeneratorUntypedBase>;
@ -28,7 +34,7 @@ namespace Catch {
} // namespace Generators } // namespace Generators
struct IGeneratorTracker { struct IGeneratorTracker {
virtual ~IGeneratorTracker(); virtual ~IGeneratorTracker(); // = default;
virtual auto hasGenerator() const -> bool = 0; virtual auto hasGenerator() const -> bool = 0;
virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0; virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0;
virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0; virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0;

View File

@ -43,9 +43,13 @@ namespace Catch {
m_result( result ) m_result( result )
{} {}
ITransientExpression() = default;
ITransientExpression(ITransientExpression const&) = default;
ITransientExpression& operator=(ITransientExpression const&) = default;
// We don't actually need a virtual destructor, but many static analysers // We don't actually need a virtual destructor, but many static analysers
// complain if it's not here :-( // complain if it's not here :-(
virtual ~ITransientExpression(); virtual ~ITransientExpression(); // = default;
bool m_isBinaryExpression; bool m_isBinaryExpression;
bool m_result; bool m_result;

View File

@ -17,8 +17,13 @@ namespace Matchers {
class MatcherUntypedBase { class MatcherUntypedBase {
public: public:
MatcherUntypedBase() = default; MatcherUntypedBase() = default;
MatcherUntypedBase(MatcherUntypedBase const&) = default; MatcherUntypedBase(MatcherUntypedBase const&) = default;
MatcherUntypedBase(MatcherUntypedBase&&) = default;
MatcherUntypedBase& operator = (MatcherUntypedBase const&) = delete; MatcherUntypedBase& operator = (MatcherUntypedBase const&) = delete;
MatcherUntypedBase& operator = (MatcherUntypedBase&&) = delete;
std::string toString() const; std::string toString() const;
protected: protected:

View File

@ -18,7 +18,14 @@
namespace Catch { namespace Catch {
namespace Matchers { namespace Matchers {
struct MatcherGenericBase : MatcherUntypedBase { struct MatcherGenericBase : MatcherUntypedBase {
MatcherGenericBase() = default;
virtual ~MatcherGenericBase(); // = default; virtual ~MatcherGenericBase(); // = default;
MatcherGenericBase(MatcherGenericBase&) = default;
MatcherGenericBase(MatcherGenericBase&&) = default;
MatcherGenericBase& operator=(MatcherGenericBase const&) = delete;
MatcherGenericBase& operator=(MatcherGenericBase&&) = delete;
}; };

View File

@ -893,11 +893,11 @@ namespace { namespace MatchersTests {
struct ThrowOnCopyOrMoveMatcher : Catch::Matchers::MatcherGenericBase { struct ThrowOnCopyOrMoveMatcher : Catch::Matchers::MatcherGenericBase {
ThrowOnCopyOrMoveMatcher() = default; ThrowOnCopyOrMoveMatcher() = default;
[[noreturn]] [[noreturn]]
ThrowOnCopyOrMoveMatcher(ThrowOnCopyOrMoveMatcher const&) { ThrowOnCopyOrMoveMatcher(ThrowOnCopyOrMoveMatcher const&): Catch::Matchers::MatcherGenericBase() {
throw MatcherWasMovedOrCopied(); throw MatcherWasMovedOrCopied();
} }
[[noreturn]] [[noreturn]]
ThrowOnCopyOrMoveMatcher(ThrowOnCopyOrMoveMatcher &&) { ThrowOnCopyOrMoveMatcher(ThrowOnCopyOrMoveMatcher &&): Catch::Matchers::MatcherGenericBase() {
throw MatcherWasMovedOrCopied(); throw MatcherWasMovedOrCopied();
} }
ThrowOnCopyOrMoveMatcher& operator=(ThrowOnCopyOrMoveMatcher const&) { ThrowOnCopyOrMoveMatcher& operator=(ThrowOnCopyOrMoveMatcher const&) {