Replace support/shared_ptr.h and boost::shared_ptr with std::shared_ptr

shared_ptrs now only require the <memory> header.
This commit is contained in:
Guillaume Munch 2016-06-02 18:13:55 +01:00
parent ca8709aaf5
commit b032e2dfaf
24 changed files with 66 additions and 95 deletions

View File

@ -107,12 +107,12 @@
#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()

View File

@ -2205,7 +2205,7 @@ bool BufferParams::hasClassDefaults() const
DocumentClass const & BufferParams::documentClass() const
{
return *doc_class_.get();
return *doc_class_;
}

View File

@ -12,13 +12,13 @@
#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

View 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;
};

View File

@ -13,9 +13,10 @@
#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

View 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,

View File

@ -16,10 +16,9 @@
#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;
};

View File

@ -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[];
};

View 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));

View 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_;
};

View 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
{

View 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);
}

View 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_;
///

View File

@ -20,10 +20,9 @@
#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;

View 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();

View 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:

View File

@ -40,9 +40,10 @@
#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;
///

View 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) {

View File

@ -28,12 +28,14 @@
#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;

View File

@ -15,10 +15,11 @@
#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_;
///

View 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;

View File

@ -14,7 +14,6 @@
#ifndef FORKEDCALLS_H
#define FORKEDCALLS_H
#include "support/shared_ptr.h"
#include "support/strfwd.h"
#include <boost/signal.hpp>
@ -22,6 +21,11 @@
# 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.

View File

@ -96,7 +96,6 @@ liblyxsupport_a_SOURCES = \
Systemcall.cpp \
Systemcall.h \
SystemcallPrivate.h \
shared_ptr.h \
TempFile.cpp \
TempFile.h \
textutils.h \

View File

@ -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