Tidy up some ConstRef<T> and Ref<T> constructor cases (#730)

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
mr-mocap 2023-08-19 05:10:29 -04:00 committed by GitHub
parent b3f1edc385
commit 1e6df78ec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -13,10 +13,11 @@ class ConstRef {
public: public:
ConstRef() = default; ConstRef() = default;
ConstRef(const ConstRef<T>&) = 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) {} ConstRef(const T* t) : variant_(t) {}
// Make a "resetable" reference // Make a "reseatable" reference
ConstRef<T>& operator=(const ConstRef<T>&) = default; ConstRef<T>& operator=(const ConstRef<T>&) = default;
// Accessors: // Accessors:
@ -39,11 +40,11 @@ class Ref {
public: public:
Ref() = default; Ref() = default;
Ref(const Ref<T>&) = default; Ref(const Ref<T>&) = default;
Ref(const T& t) : variant_(t) {} Ref(Ref<T>&&) = default;
Ref(T&& t) : variant_(std::forward<T>(t)) {} Ref(T t) : variant_(std::move(t)) {}
Ref(T* t) : variant_(t) {} Ref(T* t) : variant_(t) {}
// Make a "resetable" reference // Make a "reseatable" reference.
Ref<T>& operator=(const Ref<T>&) = default; Ref<T>& operator=(const Ref<T>&) = default;
// Accessors: // Accessors:

View File

@ -849,7 +849,7 @@ class CanvasNodeBase : public Node {
Element canvas(ConstRef<Canvas> canvas) { Element canvas(ConstRef<Canvas> canvas) {
class Impl : public CanvasNodeBase { class Impl : public CanvasNodeBase {
public: 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_x = (canvas_->width() + 1) / 2;
requirement_.min_y = (canvas_->height() + 3) / 4; requirement_.min_y = (canvas_->height() + 3) / 4;
} }