From 4fc8c7fedd4145acc7b666480d08967a77acf6d9 Mon Sep 17 00:00:00 2001 From: Guillaume MM Date: Mon, 10 Apr 2017 01:05:55 +0200 Subject: [PATCH] MathAtom: prefer composition over inheritance --- src/mathed/MathAtom.cpp | 4 ++-- src/mathed/MathAtom.h | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mathed/MathAtom.cpp b/src/mathed/MathAtom.cpp index cbf26ec9f7..10f52174b6 100644 --- a/src/mathed/MathAtom.cpp +++ b/src/mathed/MathAtom.cpp @@ -19,12 +19,12 @@ namespace lyx { MathAtom::MathAtom(InsetMath * p) - : unique_ptr(p) + : nucleus_(p) {} MathAtom::MathAtom(MathAtom const & at) - : unique_ptr(at ? static_cast(at->clone()) : nullptr) + : nucleus_(at.nucleus_ ? static_cast(at->clone()) : nullptr) {} diff --git a/src/mathed/MathAtom.h b/src/mathed/MathAtom.h index 7801fe6c5d..5d20e69bbf 100644 --- a/src/mathed/MathAtom.h +++ b/src/mathed/MathAtom.h @@ -40,15 +40,14 @@ Andre' */ -#include - +#include "support/unique_ptr.h" namespace lyx { class Inset; class InsetMath; -class MathAtom : public std::unique_ptr { +class MathAtom { public: MathAtom() = default; MathAtom(MathAtom &&) = default; @@ -59,8 +58,12 @@ public: MathAtom(MathAtom const &); MathAtom & operator=(MathAtom const &); /// access to the inset - InsetMath * nucleus() { return get(); } - InsetMath const * nucleus() const { return get(); } + InsetMath * nucleus() { return nucleus_.get(); } + InsetMath const * nucleus() const { return nucleus_.get(); } + InsetMath * operator->() { return nucleus_.get(); } + InsetMath const * operator->() const { return nucleus_.get(); } +private: + std::unique_ptr nucleus_; }; -- 2.39.2