commit 4fc8c7fedd4145acc7b666480d08967a77acf6d9
Author: Guillaume MM <g...@lyx.org>
Date:   Mon Apr 10 01:05:55 2017 +0200

    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 cbf26ec..10f5217 100644
--- a/src/mathed/MathAtom.cpp
+++ b/src/mathed/MathAtom.cpp
@@ -19,12 +19,12 @@ namespace lyx {
 
 
 MathAtom::MathAtom(InsetMath * p)
-       : unique_ptr<InsetMath>(p)
+       : nucleus_(p)
 {}
 
 
 MathAtom::MathAtom(MathAtom const & at)
-       : unique_ptr<InsetMath>(at ? static_cast<InsetMath*>(at->clone()) : 
nullptr)
+       : nucleus_(at.nucleus_ ? static_cast<InsetMath*>(at->clone()) : nullptr)
 {}
 
 
diff --git a/src/mathed/MathAtom.h b/src/mathed/MathAtom.h
index 7801fe6..5d20e69 100644
--- a/src/mathed/MathAtom.h
+++ b/src/mathed/MathAtom.h
@@ -40,15 +40,14 @@ Andre'
 
 */
 
-#include <memory>
-
+#include "support/unique_ptr.h"
 
 namespace lyx {
 
 class Inset;
 class InsetMath;
 
-class MathAtom : public std::unique_ptr<InsetMath> {
+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<InsetMath> nucleus_;
 };
 
 

Reply via email to