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

@@ -11,8 +11,7 @@ namespace ftxui {
class Blink : public NodeDecorator {
public:
Blink(Elements children) : NodeDecorator(std::move(children)) {}
~Blink() override {}
using NodeDecorator::NodeDecorator;
void Render(Screen& screen) override {
Node::Render(screen);

View File

@@ -11,8 +11,7 @@ namespace ftxui {
class Bold : public NodeDecorator {
public:
Bold(Elements children) : NodeDecorator(std::move(children)) {}
~Bold() override {}
using NodeDecorator::NodeDecorator;
void Render(Screen& screen) override {
for (int y = box_.y_min; y <= box_.y_max; ++y) {

View File

@@ -22,7 +22,6 @@ class Border : public Node {
std::end(simple_border_charset)) {}
Border(Elements children, Pixel pixel)
: Node(std::move(children)), charset_pixel(10, pixel) {}
~Border() override {}
std::vector<Pixel> charset_pixel;
std::vector<wchar_t> charset;

View File

@@ -13,8 +13,7 @@ using ftxui::Screen;
class ClearUnder : public NodeDecorator {
public:
ClearUnder(Elements children) : NodeDecorator(std::move(children)) {}
~ClearUnder() override {}
using NodeDecorator::NodeDecorator;
void Render(Screen& screen) override {
for (int y = box_.y_min; y <= box_.y_max; ++y) {

View File

@@ -30,7 +30,6 @@ class FgColor : public NodeDecorator {
public:
FgColor(Elements children, Color color)
: NodeDecorator(std::move(children)), color_(color) {}
~FgColor() override {}
void Render(Screen& screen) override {
for (int y = box_.y_min; y <= box_.y_max; ++y) {

View File

@@ -13,7 +13,6 @@ namespace ftxui {
class DBox : public Node {
public:
DBox(Elements children) : Node(std::move(children)) {}
~DBox() {}
void ComputeRequirement() override {
requirement_.min_x = 0;

View File

@@ -9,12 +9,9 @@
namespace ftxui {
using ftxui::Screen;
class Dim : public NodeDecorator {
public:
Dim(Elements children) : NodeDecorator(std::move(children)) {}
~Dim() override {}
using NodeDecorator::NodeDecorator;
void Render(Screen& screen) override {
Node::Render(screen);

View File

@@ -67,9 +67,8 @@ void function_not_flex(Requirement& r) {
class Flex : public Node {
public:
Flex(FlexFunction f) { f_ = f; }
Flex(FlexFunction f) : f_(f) {}
Flex(FlexFunction f, Element child) : Node(unpack(std::move(child))), f_(f) {}
~Flex() override {}
void ComputeRequirement() override {
requirement_.min_x = 0;
requirement_.min_y = 0;

View File

@@ -19,7 +19,6 @@ static wchar_t charset[] = L" ▏▎▍▌▋▊▉█";
class Gauge : public Node {
public:
Gauge(float progress) : progress_(progress) {}
~Gauge() override {}
void ComputeRequirement() override {
requirement_.flex_grow_x = 1;

View File

@@ -21,7 +21,6 @@ const wchar_t charset[] = L" ▗▐▖▄▟▌▙█";
class Graph : public Node {
public:
Graph(GraphFunction graph_function) : graph_function_(graph_function) {}
~Graph() override {}
void ComputeRequirement() override {
requirement_.flex_grow_x = 1;

View File

@@ -13,7 +13,6 @@ namespace ftxui {
class HBox : public Node {
public:
HBox(Elements children) : Node(std::move(children)) {}
~HBox() {}
void ComputeRequirement() override {
requirement_.min_x = 0;

View File

@@ -13,7 +13,6 @@ namespace ftxui {
class HFlow : public Node {
public:
HFlow(Elements children) : Node(std::move(children)) {}
~HFlow() {}
void ComputeRequirement() override {
requirement_.min_x = 1;

View File

@@ -9,12 +9,9 @@
namespace ftxui {
using ftxui::Screen;
class Inverted : public NodeDecorator {
public:
Inverted(Elements children) : NodeDecorator(std::move(children)) {}
~Inverted() override {}
using NodeDecorator::NodeDecorator;
void Render(Screen& screen) override {
Node::Render(screen);

View File

@@ -5,8 +5,6 @@
namespace ftxui {
using ftxui::Screen;
Node::Node() {}
Node::Node(Elements children) : children_(std::move(children)) {}
Node::~Node() {}

View File

@@ -12,7 +12,6 @@ struct Box;
class NodeDecorator : public Node {
public:
NodeDecorator(Elements children) : Node(std::move(children)) {}
~NodeDecorator() override {}
void ComputeRequirement() override;
void SetBox(Box box) override;
};

View File

@@ -14,7 +14,6 @@ class Reflect : public Node {
public:
Reflect(Element child, Box& box)
: Node(unpack(std::move(child))), reflected_box_(box) {}
~Reflect() override {}
void ComputeRequirement() final {
Node::ComputeRequirement();

View File

@@ -13,8 +13,6 @@ using ftxui::Screen;
class Separator : public Node {
public:
Separator() {}
~Separator() override {}
void ComputeRequirement() override {
requirement_.min_x = 1;
requirement_.min_y = 1;
@@ -41,7 +39,6 @@ class Separator : public Node {
class SeparatorWithPixel : public Separator {
public:
SeparatorWithPixel(Pixel pixel) : pixel_(pixel) {}
~SeparatorWithPixel() override {}
void Render(Screen& screen) override {
for (int y = box_.y_min; y <= box_.y_max; ++y) {
for (int x = box_.x_min; x <= box_.x_max; ++x) {

View File

@@ -19,8 +19,6 @@ class Size : public Node {
constraint_(constraint),
value_(value) {}
~Size() override {}
void ComputeRequirement() override {
Node::ComputeRequirement();
requirement_ = children_[0]->requirement();

View File

@@ -15,8 +15,7 @@ using ftxui::Screen;
class Text : public Node {
public:
Text(std::wstring text) : Node(), text_(text) {}
~Text() {}
Text(std::wstring text) : text_(text) {}
void ComputeRequirement() override {
requirement_.min_x = wstring_width(text_);
@@ -47,11 +46,10 @@ class Text : public Node {
class VText : public Node {
public:
VText(std::wstring text) : Node(), text_(text) {
VText(std::wstring text) : text_(text) {
for (auto& c : text_)
width_ = std::max(width_, wchar_width(c));
}
~VText() {}
void ComputeRequirement() override {
requirement_.min_x = width_;

View File

@@ -9,12 +9,9 @@
namespace ftxui {
using ftxui::Screen;
class Underlined : public NodeDecorator {
public:
Underlined(Elements children) : NodeDecorator(std::move(children)) {}
~Underlined() override {}
using NodeDecorator::NodeDecorator;
void Render(Screen& screen) override {
Node::Render(screen);

View File

@@ -13,7 +13,6 @@ namespace ftxui {
class VBox : public Node {
public:
VBox(Elements children) : Node(std::move(children)) {}
~VBox() {}
void ComputeRequirement() override {
requirement_.min_x = 0;