Skip to content

Commit

Permalink
Tidy up some ConstRef<T> and Ref<T> constructor cases (#730)
Browse files Browse the repository at this point in the history
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
  • Loading branch information
mr-mocap and ArthurSonzogni committed Aug 19, 2023
1 parent b3f1edc commit 1e6df78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions include/ftxui/util/ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ class ConstRef {
public:
ConstRef() = default;
ConstRef(const ConstRef<T>&) = default;
ConstRef(const T& t) : variant_(t) {}
ConstRef(ConstRef<T>&&) = default;
ConstRef(T t) : variant_(std::move(t)) {}
ConstRef(const T* t) : variant_(t) {}

// Make a "resetable" reference
// Make a "reseatable" reference
ConstRef<T>& operator=(const ConstRef<T>&) = default;

// Accessors:
Expand All @@ -39,11 +40,11 @@ class Ref {
public:
Ref() = default;
Ref(const Ref<T>&) = default;
Ref(const T& t) : variant_(t) {}
Ref(T&& t) : variant_(std::forward<T>(t)) {}
Ref(Ref<T>&&) = default;
Ref(T t) : variant_(std::move(t)) {}
Ref(T* t) : variant_(t) {}

// Make a "resetable" reference
// Make a "reseatable" reference.
Ref<T>& operator=(const Ref<T>&) = default;

// Accessors:
Expand Down
2 changes: 1 addition & 1 deletion src/ftxui/dom/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ class CanvasNodeBase : public Node {
Element canvas(ConstRef<Canvas> canvas) {
class Impl : public CanvasNodeBase {
public:
explicit Impl(ConstRef<Canvas> canvas) : canvas_(canvas) {
explicit Impl(ConstRef<Canvas> canvas) : canvas_(std::move(canvas)) {
requirement_.min_x = (canvas_->width() + 1) / 2;
requirement_.min_y = (canvas_->height() + 3) / 4;
}
Expand Down

0 comments on commit 1e6df78

Please sign in to comment.