Remove explicit default destructors (#157)

From CppCoreGuidelines:

Rule of Zero: C.20: If you can avoid defining default operations, do.
C.52: Use inheriting constructors to import constructors into a derived class that does not need further explicit initialization.
DRY forward and using declarations.
Miscellaneous:

Fix format.sh to output examples with normalised paths in sorted order.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
Tushar Maheshwari
2021-07-17 15:32:08 +05:30
committed by GitHub
parent b3a333b417
commit 21d746e858
38 changed files with 67 additions and 125 deletions

View File

@@ -23,8 +23,6 @@ class ButtonBase : public ComponentBase {
Ref<ButtonOption> option)
: label_(label), on_click_(on_click), option_(std::move(option)) {}
~ButtonBase() override = default;
// Component implementation:
Element Render() override {
auto style = Focused() ? inverted : nothing;

View File

@@ -13,7 +13,6 @@ class CatchEventBase : public ComponentBase {
// Constructor.
CatchEventBase(std::function<bool(Event)> on_event)
: on_event_(std::move(on_event)) {}
~CatchEventBase() override = default;
// Component implementation.
bool OnEvent(Event event) override {

View File

@@ -29,8 +29,6 @@ class CheckboxBase : public ComponentBase {
#endif
}
~CheckboxBase() override = default;
private:
// Component implementation.
Element Render() override {

View File

@@ -14,10 +14,7 @@
namespace ftxui {
namespace {
class CaptureMouseImpl : public CapturedMouseInterface {
public:
~CaptureMouseImpl() override {}
};
class CaptureMouseImpl : public CapturedMouseInterface {};
} // namespace
ComponentBase::~ComponentBase() {
@@ -161,9 +158,9 @@ void ComponentBase::TakeFocus() {
/// @param event
/// @ingroup component
CapturedMouse ComponentBase::CaptureMouse(const Event& event) {
if (!event.screen_)
return std::make_unique<CaptureMouseImpl>();
return event.screen_->CaptureMouse();
if (event.screen_)
return event.screen_->CaptureMouse();
return std::make_unique<CaptureMouseImpl>();
}
} // namespace ftxui

View File

@@ -53,8 +53,6 @@ class ContainerBase : public ComponentBase {
return container;
}
~ContainerBase() override = default;
// Component override.
bool OnEvent(Event event) override {
if (event.is_mouse())

View File

@@ -24,7 +24,6 @@ class InputBase : public ComponentBase {
ConstStringRef placeholder,
Ref<InputOption> option)
: content_(content), placeholder_(placeholder), option_(option) {}
~InputBase() override = default;
int& cursor_position() { return *(option_->cursor_position); }

View File

@@ -38,7 +38,6 @@ class RadioboxBase : public ComponentBase {
option_->style_unchecked = L"( )";
#endif
}
~RadioboxBase() override = default;
private:
Element Render() override {

View File

@@ -18,7 +18,6 @@ class RendererBase : public ComponentBase {
// Constructor.
RendererBase(std::function<Element()> render) : render_(std::move(render)) {}
~RendererBase() override = default;
// Component implementation.
Element Render() override { return render_(); }

View File

@@ -29,8 +29,6 @@ class ToggleBase : public ComponentBase {
Ref<ToggleOption> option)
: entries_(entries), selected_(selected), option_(std::move(option)) {}
~ToggleBase() override = default;
private:
Element Render() override {
Elements children;