]> git.lyx.org Git - features.git/commitdiff
Replace support/shared_ptr.h and boost::shared_ptr with std::shared_ptr
authorGuillaume Munch <gm@lyx.org>
Thu, 2 Jun 2016 17:13:55 +0000 (18:13 +0100)
committerGuillaume Munch <gm@lyx.org>
Thu, 9 Jun 2016 14:21:39 +0000 (15:21 +0100)
shared_ptrs now only require the <memory> header.

24 files changed:
src/Buffer.cpp
src/BufferParams.cpp
src/DocumentClassPtr.h
src/KeyMap.h
src/OutputParams.h
src/ServerSocket.cpp
src/ServerSocket.h
src/Toc.h
src/TocBackend.cpp
src/TocBackend.h
src/frontends/qt4/Menus.cpp
src/frontends/qt4/TocModel.cpp
src/frontends/qt4/TocModel.h
src/graphics/GraphicsCache.h
src/graphics/GraphicsCacheItem.cpp
src/graphics/GraphicsLoader.cpp
src/graphics/PreviewLoader.cpp
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
src/output_xhtml.h
src/support/ForkedCalls.cpp
src/support/ForkedCalls.h
src/support/Makefile.am
src/support/shared_ptr.h [deleted file]

index 431f3f6c920c0a6769031b0e1bbe1ee5125e3e9f..084b94c03f7d6ccba50e3f01868218c4d737e275 100644 (file)
 #include "support/types.h"
 
 #include "support/bind.h"
-#include "support/shared_ptr.h"
 
 #include <algorithm>
 #include <fstream>
 #include <iomanip>
 #include <map>
+#include <memory>
 #include <set>
 #include <sstream>
 #include <vector>
@@ -3847,7 +3847,7 @@ public:
        ///
        virtual shared_ptr<ForkedProcess> clone() const
        {
-               return shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
+               return make_shared<AutoSaveBuffer>(*this);
        }
        ///
        int start()
index bcf8d6450330495a537ce0a5458bf84ceeed8a1e..2d113bad4579bbc7851700c03ce4e59048a92c7e 100644 (file)
@@ -2205,7 +2205,7 @@ bool BufferParams::hasClassDefaults() const
 
 DocumentClass const & BufferParams::documentClass() const
 {
-       return *doc_class_.get();
+       return *doc_class_;
 }
 
 
index eef9ac26753e7cb2d3c2e3a200900245467bfbe8..b2c95a00235457e2a1892a19e503415102ac0978 100644 (file)
 #ifndef DOCUMENT_CLASS_PTR_H
 #define DOCUMENT_CLASS_PTR_H
 
-#include "support/shared_ptr.h"
+#include <memory>
 
 namespace lyx {
 class DocumentClass;
 
-typedef shared_ptr<DocumentClass> DocumentClassPtr;
-typedef shared_ptr<DocumentClass const> DocumentClassConstPtr;
+typedef std::shared_ptr<DocumentClass> DocumentClassPtr;
+typedef std::shared_ptr<DocumentClass const> DocumentClassConstPtr;
 }
 
 #endif // DISPATCH_RESULT_H
index cd28782356ac98336fb791def7b84c5d5824d789..f6a82c082c0245b3aa2eb1a14932a55fe044519c 100644 (file)
@@ -19,8 +19,7 @@
 
 #include "support/strfwd.h"
 
-#include "support/shared_ptr.h"
-
+#include <memory>
 #include <vector>
 
 
@@ -163,7 +162,7 @@ private:
                /// Modifier masks
                ModifierPair mod;
                /// Keymap for prefix keys
-               shared_ptr<KeyMap> prefixes;
+               std::shared_ptr<KeyMap> prefixes;
                /// Action for !prefix keys
                FuncRequest func;
        };
index 16fe7c4a765a03d75c64401aceda0c90d5f179a3..ccb0783a2a95a9067a7d72c331d2854df55fdb90 100644 (file)
 #define OUTPUTPARAMS_H
 
 
-#include "support/shared_ptr.h"
 #include "Changes.h"
 
+#include <memory>
+
 
 namespace lyx {
 
@@ -182,7 +183,7 @@ public:
            This is a hack: Make it possible to add stuff to constant
            OutputParams instances.
        */
-       shared_ptr<ExportData> exportdata;
+       std::shared_ptr<ExportData> exportdata;
 
        /** Whether we are inside a comment inset. Insets that are including
         *  external files like InsetGraphics, InsetInclude and InsetExternal
index fb6e3bf75c6abe24c62e7c7b05ad683041b6df74..72a70d4edaac9bcede9ede09fa9d0709055ce3c8 100644 (file)
@@ -110,8 +110,7 @@ void ServerSocket::serverCallback()
        }
 
        // Register the new client.
-       clients[client_fd] =
-               shared_ptr<LyXDataSocket>(new LyXDataSocket(client_fd));
+       clients[client_fd] = make_shared<LyXDataSocket>(client_fd);
        theApp()->registerSocketCallback(
                client_fd,
                bind(&ServerSocket::dataCallback,
index 7364250e17b7174dfb791490706d2f48c7cfaaac..c66658042ff38ca4d4da9dfda9d67cb9489567c0 100644 (file)
 
 #include "support/FileName.h"
 
-#include "support/shared_ptr.h"
-
 #include <string>
 #include <map>
+#include <memory>
 
 
 namespace lyx {
@@ -60,7 +59,7 @@ private:
                MAX_CLIENTS = 10
        };
        /// All connections
-       std::map<int, shared_ptr<LyXDataSocket> > clients;
+       std::map<int, std::shared_ptr<LyXDataSocket>> clients;
 };
 
 
index 82f7ce170191a6d56275169fbf78d7bae145d8dd..bd6bdf2d4bffdc5c485691f428d2e54ca20c5df3 100644 (file)
--- a/src/Toc.h
+++ b/src/Toc.h
@@ -15,9 +15,8 @@
 #ifndef TOC_H
 #define TOC_H
 
-#include "support/shared_ptr.h"
-
 #include <map>
+#include <memory>
 #include <vector>
 #include <string>
 
@@ -29,12 +28,12 @@ class TocItem;
 
 typedef std::vector<TocItem> Toc;
 
-class TocList : public std::map<std::string, shared_ptr<Toc> >
+class TocList : public std::map<std::string, std::shared_ptr<Toc>>
 {
 private:
        // TocList should never map to null pointers.
-       // We forbid the following method which creates null pointers.
-       using std::map<std::string, shared_ptr<Toc> >::operator[];
+       // We hide the following methods which create null pointers.
+       using std::map<std::string, std::shared_ptr<Toc>>::operator[];
 };
 
 
index 6526c57537ae53acadfef5079c6e5a31a1dd82e4..e8c430d8eb6639acbccc8cbfb161d06d46d83376 100644 (file)
@@ -153,7 +153,7 @@ Toc::iterator TocBackend::findItem(Toc & toc, int depth, docstring const & str)
 ///////////////////////////////////////////////////////////////////////////
 
 TocBuilder::TocBuilder(shared_ptr<Toc> toc)
-       : toc_(toc ? toc : lyx::make_shared<Toc>()),
+       : toc_(toc ? toc : make_shared<Toc>()),
          stack_()
 {
        LATTEST(toc);
@@ -214,13 +214,11 @@ void TocBuilder::pop()
 ///////////////////////////////////////////////////////////////////////////
 
 shared_ptr<TocBuilder> TocBuilderStore::get(string const & type,
-                                                                                       shared_ptr<Toc> toc)
+                                            shared_ptr<Toc> toc)
 {
        map_t::const_iterator it = map_.find(type);
-       if (it == map_.end()) {
-               it = map_.insert(std::make_pair(type,
-                                                                       lyx::make_shared<TocBuilder>(toc))).first;
-       }
+       if (it == map_.end())
+               it = map_.insert(make_pair(type, make_shared<TocBuilder>(toc))).first;
        return it->second;
 }
 
@@ -236,7 +234,7 @@ shared_ptr<Toc const> TocBackend::toc(string const & type) const
 {
        // Is the type already supported?
        TocList::const_iterator it = tocs_.find(type);
-       LASSERT(it != tocs_.end(), { return lyx::make_shared<Toc>(); });
+       LASSERT(it != tocs_.end(), { return make_shared<Toc>(); });
        return it->second;
 }
 
@@ -244,9 +242,8 @@ shared_ptr<Toc const> TocBackend::toc(string const & type) const
 shared_ptr<Toc> TocBackend::toc(string const & type)
 {
        TocList::const_iterator it = tocs_.find(type);
-       if (it == tocs_.end()) {
-               it = tocs_.insert(std::make_pair(type, lyx::make_shared<Toc>())).first;
-       }
+       if (it == tocs_.end())
+               it = tocs_.insert(make_pair(type, make_shared<Toc>())).first;
        return it->second;
 }
 
@@ -357,7 +354,7 @@ void TocBackend::writePlaintextTocList(string const & type,
 }
 
 
-docstring TocBackend::outlinerName(std::string const & type) const
+docstring TocBackend::outlinerName(string const & type) const
 {
        return translateIfPossible(
            buffer_->params().documentClass().outlinerName(type));
index 2520927406dd15a2cebbf5aa86d4cf9d9be96c2d..1579cf2fdcd0b34ba9b9c3311a7add50f0b107a9 100644 (file)
@@ -25,6 +25,8 @@
 #include <stack>
 
 
+using std::shared_ptr;
+
 namespace lyx {
 
 class Buffer;
@@ -156,7 +158,7 @@ public:
        ///
        void clear() { map_.clear(); };
 private:
-       typedef std::map<std::string, shared_ptr<TocBuilder> > map_t;
+       typedef std::map<std::string, shared_ptr<TocBuilder>> map_t;
        map_t map_;
 };
 
index ea32aace5b7af5f28f3e480ff5eba460437534e4..0d80b56f1a493b7bb699376ad768d0fe20fe7f40 100644 (file)
@@ -78,9 +78,8 @@
 #include <QProxyStyle>
 #endif
 
-#include "support/shared_ptr.h"
-
 #include <algorithm>
+#include <memory>
 #include <vector>
 
 using namespace std;
@@ -217,9 +216,6 @@ public:
                func_.setOrigin(origin);
        }
 
-       // shared_ptr<MenuDefinition> needs this apprently...
-       ~MenuItem() {}
-
        /// The label of a given menuitem
        QString label() const
        {
index 9fb94813d215c4a7fc19dc736fafd26e24586f7a..eb6e610a1b4f5d322fdcbf870e9b397b01f9ab8a 100644 (file)
@@ -74,7 +74,7 @@ public:
 TocModel::TocModel(QObject * parent)
        : model_(new TocTypeModel(parent)),
          sorted_model_(new QSortFilterProxyModel(parent)),
-         is_sorted_(false), toc_(lyx::make_shared<Toc const>()),
+         is_sorted_(false), toc_(new Toc()),
          maxdepth_(0), mindepth_(0)
 {
        sorted_model_->setSortLocaleAware(true);
@@ -102,7 +102,7 @@ void TocModel::clear()
 {
        model_->blockSignals(true);
        model_->clear();
-       toc_ = lyx::make_shared<Toc const>();
+       toc_ = make_shared<Toc>();
        model_->blockSignals(false);
 }
 
index f0f9efa3196fda249010177afe62c320529d0d70..7b22ce6230f007f5ed5dfd61708dbc435354d314 100644 (file)
@@ -14,8 +14,6 @@
 
 #include "Toc.h"
 
-#include "support/shared_ptr.h"
-
 #include <QHash>
 #include <QSortFilterProxyModel>
 
@@ -41,7 +39,7 @@ public:
        ///
        TocModel(QObject * parent);
        ///
-       void reset(shared_ptr<Toc const>);
+       void reset(std::shared_ptr<Toc const>);
        ///
        void reset();
        ///
@@ -73,7 +71,7 @@ private:
        ///
        bool is_sorted_;
        ///
-       shared_ptr<Toc const> toc_;
+       std::shared_ptr<Toc const> toc_;
        ///
        int maxdepth_;
        ///
index e6d810ff429148e49e0f2d86adc5fe5e87ebb9b1..66cfc85bf6e490160b1b91886b80425fd2781cd2 100644 (file)
 #ifndef GRAPHICSCACHE_H
 #define GRAPHICSCACHE_H
 
-#include "support/shared_ptr.h"
-
-#include <vector>
+#include <memory>
 #include <string>
+#include <vector>
 
 
 namespace lyx {
@@ -65,7 +64,7 @@ public:
         *
         *  You have been warned!
         */
-       typedef shared_ptr<CacheItem> ItemPtr;
+       typedef std::shared_ptr<CacheItem> ItemPtr;
        ///
        ItemPtr const item(support::FileName const & file) const;
 
index 2d004c93e65db306be0e4417775c27f1a3a741af..0b262ad24126d966a195e96f4263051b66d35a10 100644 (file)
@@ -109,7 +109,7 @@ public:
        bool remove_loaded_file_;
 
        /// The image and its loading status.
-       shared_ptr<Image> image_;
+       std::shared_ptr<Image> image_;
        ///
        ImageStatus status_;
 
@@ -244,7 +244,7 @@ void CacheItem::Impl::reset()
        if (cc_.connected())
                cc_.disconnect();
 
-       if (converter_.get())
+       if (converter_)
                converter_.reset();
 }
 
@@ -264,8 +264,8 @@ void CacheItem::Impl::imageConverted(bool success)
        string const text = success ? "succeeded" : "failed";
        LYXERR(Debug::GRAPHICS, "Image conversion " << text << '.');
 
-       file_to_load_ = converter_.get() ?
-               FileName(converter_->convertedFile()) : FileName();
+       file_to_load_ = converter_ ? FileName(converter_->convertedFile())
+                                      : FileName();
        converter_.reset();
        cc_.disconnect();
 
index 23ebb623948f9fee8bc9b6c27951fe92e28b1f33..79f5d9d5f3325f1a198c83d3b8003afaf6898aad 100644 (file)
@@ -22,8 +22,9 @@
 
 #include "support/bind.h"
 
-#include <set>
 #include <queue>
+#include <memory>
+#include <set>
 
 using namespace std;
 using namespace lyx::support;
@@ -159,7 +160,7 @@ void LoaderQueue::touch(Cache::ItemPtr const & item)
 //
 /////////////////////////////////////////////////////////////////////
 
-typedef shared_ptr<Image> ImagePtr;
+typedef std::shared_ptr<Image> ImagePtr;
 
 class Loader::Impl : public boost::signals::trackable {
 public:
index 88320e4517b5106ce3cd1d13f7177b2a9a4cdcef..b273aa4a690992e730ee6f4686d1b095da376b37 100644 (file)
 #include "support/bind.h"
 #include "support/TempFile.h"
 
-#include <sstream>
 #include <fstream>
 #include <iomanip>
+#include <memory>
+#include <sstream>
 
 #include <QTimer>
 
@@ -229,7 +230,7 @@ private:
        /** cache_ allows easy retrieval of already-generated images
         *  using the LaTeX snippet as the identifier.
         */
-       typedef shared_ptr<PreviewImage> PreviewImagePtr;
+       typedef std::shared_ptr<PreviewImage> PreviewImagePtr;
        ///
        typedef map<string, PreviewImagePtr> Cache;
        ///
index f56991470c89ef367d30d7099ff9d73565d8c5bb..c88888aa79bbb11b9d90ef72cf3032de06c447b4 100644 (file)
@@ -1102,7 +1102,7 @@ void Tabular::setAlignment(idx_type cell, LyXAlignment align,
                        dpoint = from_utf8(lyxrc.default_decimal_point);
        } else {
                cellInfo(cell).alignment = align;
-               cellInset(cell).get()->setContentAlignment(align);
+               cellInset(cell)->setContentAlignment(align);
        }
 }
 
@@ -2605,7 +2605,7 @@ void Tabular::TeXRow(otexstream & os, row_type row,
 
                if (getAlignment(cell) == LYX_ALIGN_DECIMAL) {
                        // copy cell and split in 2
-                       InsetTableCell head = InsetTableCell(*cellInset(cell).get());
+                       InsetTableCell head = InsetTableCell(*cellInset(cell));
                        head.setBuffer(buffer());
                        DocIterator dit = cellInset(cell)->getText(0)->macrocontextPosition();
                        dit.pop_back();
@@ -3615,7 +3615,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
                        // determine horizontal offset because of decimal align (if necessary)
                        int decimal_width = 0;
                        if (tabular.getAlignment(cell) == LYX_ALIGN_DECIMAL) {
-                               InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell).get());
+                               InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell));
                                tail.setBuffer(tabular.buffer());
                                // we need to set macrocontext position everywhere
                                // otherwise we crash with nested insets (e.g. footnotes)
@@ -4934,7 +4934,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                }
                // check if there is already a caption
                bool have_caption = false;
-               InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx()).get());
+               InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx()));
                ParagraphList::const_iterator pit = itc.paragraphs().begin();
                ParagraphList::const_iterator pend = itc.paragraphs().end();
                for (; pit != pend; ++pit) {
index f63b84af420329812e6c234797ff7079bdcf033f..f57cbaea13df60710909c94207480ae4ffc6c695 100644 (file)
 #include "InsetText.h"
 #include "Length.h"
 
-#include "support/shared_ptr.h"
-
 #include <climits>
 #include <iosfwd>
+#include <memory>
 #include <vector>
 
+
+using std::shared_ptr;
+
 namespace lyx {
 
 class Buffer;
index 473ebe335a41a744e83663c22aab32fefdf1de8e..a2eac95ab437881bf06926839fe04e786aae94ac 100644 (file)
 #include "LayoutEnums.h"
 
 #include "support/docstream.h"
-#include "support/shared_ptr.h"
 #include "support/strfwd.h"
 
 #include <deque>
+#include <memory>
+
 
 namespace lyx {
 
@@ -275,12 +276,11 @@ private:
        // own these pointers and how they will be deleted, so we use shared
        // pointers.
        ///
-       typedef shared_ptr<html::StartTag> TagPtr;
+       typedef std::shared_ptr<html::StartTag> TagPtr;
        typedef std::deque<TagPtr> TagDeque;
        ///
        template <typename T>
-       shared_ptr<T> makeTagPtr(T const & tag)
-               { return shared_ptr<T>(new T(tag)); }
+       TagPtr makeTagPtr(T const & tag) { return std::make_shared<T>(tag); }
        ///
        TagDeque pending_tags_;
        ///
index 14be7af6ebfb81cd590b5a726f146975168a61d7..56582a3346ee3f5db1ad5b2117b6668e37a06494 100644 (file)
@@ -553,7 +553,7 @@ string const getChildErrorMessage()
 
 namespace ForkedCallsController {
 
-typedef shared_ptr<ForkedProcess> ForkedProcessPtr;
+typedef std::shared_ptr<ForkedProcess> ForkedProcessPtr;
 typedef list<ForkedProcessPtr> ListType;
 typedef ListType::iterator iterator;
 
index 191a2b5950ef657af1b8f618b18c36fe80d3a234..a4cb766c478cec843f37021cb41410f6b0ffb531 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef FORKEDCALLS_H
 #define FORKEDCALLS_H
 
-#include "support/shared_ptr.h"
 #include "support/strfwd.h"
 #include <boost/signal.hpp>
 
 # include <sys/types.h>
 #endif
 
+#include <memory>
+
+
+using std::shared_ptr;
+
 namespace lyx {
 namespace support {
 
@@ -154,7 +158,7 @@ public:
                   std::string const & lpath = empty_string());
        ///
        virtual shared_ptr<ForkedProcess> clone() const {
-               return shared_ptr<ForkedProcess>(new ForkedCall(*this));
+               return std::make_shared<ForkedCall>(*this);
        }
 
        /** Start the child process.
index d926e868f826548c3b3c62e8cf95f0ac58bece74..1487285d69058203428e13030a2715c809109149 100644 (file)
@@ -96,7 +96,6 @@ liblyxsupport_a_SOURCES = \
        Systemcall.cpp \
        Systemcall.h \
        SystemcallPrivate.h \
-       shared_ptr.h \
        TempFile.cpp \
        TempFile.h \
        textutils.h \
diff --git a/src/support/shared_ptr.h b/src/support/shared_ptr.h
deleted file mode 100644 (file)
index ef9e1ad..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// -*- C++ -*-
-/**
- * \file shared_ptr.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Peter Kümmel
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYX_SHARED_PTR_H
-#define LYX_SHARED_PTR_H
-
-#include <memory>
-
-namespace lyx
-{
-       using std::shared_ptr;
-       using std::make_shared;
-       using std::const_pointer_cast;
-}
-
-
-#endif