Skip to content

Commit

Permalink
Remove redundant destructors
Browse files Browse the repository at this point in the history
Classes will automatically inherit the virtual-ness of their base
class destructors. If the base class already has a virtual
destructor and the derived class needs default destructor semantics
then the derived class can omit defining the destructor in favor of
the compiler automatically defining it.

This has an additional benefit of reenabling move semantics. The
presence of a user-specified destructor automatically disables move
operations.
  • Loading branch information
ChrisThrasher authored and horenmar committed Jan 14, 2024
1 parent d79bfa0 commit 05786fa
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 32 deletions.
13 changes: 0 additions & 13 deletions extras/catch_amalgamated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7304,12 +7304,6 @@ namespace Detail {
}

public:
~IGenerator() override = default;
IGenerator() = default;
IGenerator(IGenerator const&) = default;
IGenerator& operator=(IGenerator const&) = default;


// Returns the current element of the generator
//
// \Precondition The generator is either freshly constructed,
Expand Down Expand Up @@ -10707,8 +10701,6 @@ namespace Catch {

class TestRegistry : public ITestCaseRegistry {
public:
~TestRegistry() override = default;

void registerTest( Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker );

std::vector<TestCaseInfo*> const& getAllInfos() const override;
Expand Down Expand Up @@ -13376,8 +13368,6 @@ namespace Catch {
public:
JunitReporter(ReporterConfig&& _config);

~JunitReporter() override = default;

static std::string getDescription();

void testRunStarting(TestRunInfo const& runInfo) override;
Expand Down Expand Up @@ -13618,8 +13608,6 @@ namespace Catch {
m_shouldStoreSuccesfulAssertions = false;
}

~SonarQubeReporter() override = default;

static std::string getDescription() {
using namespace std::string_literals;
return "Reports test results in the Generic Test Data SonarQube XML format"s;
Expand Down Expand Up @@ -13666,7 +13654,6 @@ namespace Catch {
StreamingReporterBase( CATCH_MOVE(config) ) {
m_preferences.shouldReportAllAssertions = true;
}
~TAPReporter() override = default;

static std::string getDescription() {
using namespace std::string_literals;
Expand Down
6 changes: 0 additions & 6 deletions src/catch2/generators/catch_generators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ namespace Detail {
}

public:
~IGenerator() override = default;
IGenerator() = default;
IGenerator(IGenerator const&) = default;
IGenerator& operator=(IGenerator const&) = default;


// Returns the current element of the generator
//
// \Precondition The generator is either freshly constructed,
Expand Down
5 changes: 0 additions & 5 deletions src/catch2/internal/catch_istream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ namespace Detail {
CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << '\'' );
m_ofs << std::unitbuf;
}
~FileStream() override = default;
public: // IStream
std::ostream& stream() override {
return m_ofs;
Expand All @@ -95,7 +94,6 @@ namespace Detail {
// Store the streambuf from cout up-front because
// cout may get redirected when running tests
CoutStream() : m_os( Catch::cout().rdbuf() ) {}
~CoutStream() override = default;

public: // IStream
std::ostream& stream() override { return m_os; }
Expand All @@ -109,7 +107,6 @@ namespace Detail {
// Store the streambuf from cerr up-front because
// cout may get redirected when running tests
CerrStream(): m_os( Catch::cerr().rdbuf() ) {}
~CerrStream() override = default;

public: // IStream
std::ostream& stream() override { return m_os; }
Expand All @@ -127,8 +124,6 @@ namespace Detail {
m_os( m_streamBuf.get() )
{}

~DebugOutStream() override = default;

public: // IStream
std::ostream& stream() override { return m_os; }
};
Expand Down
1 change: 0 additions & 1 deletion src/catch2/internal/catch_run_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ namespace Catch {
TrackerContext& ctx,
ITracker* parent ):
TrackerBase( CATCH_MOVE( nameAndLocation ), ctx, parent ) {}
~GeneratorTracker() override = default;

static GeneratorTracker*
acquire( TrackerContext& ctx,
Expand Down
2 changes: 0 additions & 2 deletions src/catch2/internal/catch_test_case_registry_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ namespace Catch {

class TestRegistry : public ITestCaseRegistry {
public:
~TestRegistry() override = default;

void registerTest( Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker );

std::vector<TestCaseInfo*> const& getAllInfos() const override;
Expand Down
2 changes: 0 additions & 2 deletions src/catch2/reporters/catch_reporter_junit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ namespace Catch {
public:
JunitReporter(ReporterConfig&& _config);

~JunitReporter() override = default;

static std::string getDescription();

void testRunStarting(TestRunInfo const& runInfo) override;
Expand Down
2 changes: 0 additions & 2 deletions src/catch2/reporters/catch_reporter_sonarqube.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ namespace Catch {
m_shouldStoreSuccesfulAssertions = false;
}

~SonarQubeReporter() override = default;

static std::string getDescription() {
using namespace std::string_literals;
return "Reports test results in the Generic Test Data SonarQube XML format"s;
Expand Down
1 change: 0 additions & 1 deletion src/catch2/reporters/catch_reporter_tap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace Catch {
StreamingReporterBase( CATCH_MOVE(config) ) {
m_preferences.shouldReportAllAssertions = true;
}
~TAPReporter() override = default;

static std::string getDescription() {
using namespace std::string_literals;
Expand Down

0 comments on commit 05786fa

Please sign in to comment.