From 1e6df78ec2700231a980748fa442c7d87c083c05 Mon Sep 17 00:00:00 2001 From: mr-mocap <16119203+mr-mocap@users.noreply.github.com> Date: Sat, 19 Aug 2023 05:10:29 -0400 Subject: [PATCH] Tidy up some ConstRef and Ref constructor cases (#730) Co-authored-by: ArthurSonzogni --- include/ftxui/util/ref.hpp | 11 ++++++----- src/ftxui/dom/canvas.cpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/ftxui/util/ref.hpp b/include/ftxui/util/ref.hpp index 1207af5..7871479 100644 --- a/include/ftxui/util/ref.hpp +++ b/include/ftxui/util/ref.hpp @@ -13,10 +13,11 @@ class ConstRef { public: ConstRef() = default; ConstRef(const ConstRef&) = default; - ConstRef(const T& t) : variant_(t) {} + ConstRef(ConstRef&&) = default; + ConstRef(T t) : variant_(std::move(t)) {} ConstRef(const T* t) : variant_(t) {} - // Make a "resetable" reference + // Make a "reseatable" reference ConstRef& operator=(const ConstRef&) = default; // Accessors: @@ -39,11 +40,11 @@ class Ref { public: Ref() = default; Ref(const Ref&) = default; - Ref(const T& t) : variant_(t) {} - Ref(T&& t) : variant_(std::forward(t)) {} + Ref(Ref&&) = default; + Ref(T t) : variant_(std::move(t)) {} Ref(T* t) : variant_(t) {} - // Make a "resetable" reference + // Make a "reseatable" reference. Ref& operator=(const Ref&) = default; // Accessors: diff --git a/src/ftxui/dom/canvas.cpp b/src/ftxui/dom/canvas.cpp index f42efb6..f6501fd 100644 --- a/src/ftxui/dom/canvas.cpp +++ b/src/ftxui/dom/canvas.cpp @@ -849,7 +849,7 @@ class CanvasNodeBase : public Node { Element canvas(ConstRef canvas) { class Impl : public CanvasNodeBase { public: - explicit Impl(ConstRef canvas) : canvas_(canvas) { + explicit Impl(ConstRef canvas) : canvas_(std::move(canvas)) { requirement_.min_x = (canvas_->width() + 1) / 2; requirement_.min_y = (canvas_->height() + 3) / 4; }