mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Remove non-copyable idioms
Two better ways of making a class non-copyable in C++11: * Store the p. impl. in a unique_ptr (for the cases of classes with p. impl.), or: * Define publicly the copy constructor and assignment as deleted Lots of other classes could be cleaned up in this way.
This commit is contained in:
parent
973618e1c1
commit
8d640dc776
@ -73,9 +73,8 @@ struct WordList::Impl {
|
||||
};
|
||||
|
||||
|
||||
WordList::WordList()
|
||||
WordList::WordList() : d(new Impl)
|
||||
{
|
||||
d = new Impl;
|
||||
d->c_ = 0;
|
||||
|
||||
#if 0
|
||||
@ -86,12 +85,6 @@ WordList::WordList()
|
||||
}
|
||||
|
||||
|
||||
WordList::~WordList()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
docstring const & WordList::word(size_t idx) const
|
||||
{
|
||||
Impl::Words::const_iterator it = d->words_.find_summed_weight(idx);
|
||||
|
@ -14,18 +14,14 @@
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class WordList {
|
||||
// noncopyable because of pimpl
|
||||
WordList(WordList const &);
|
||||
WordList & operator=(WordList const &);
|
||||
public:
|
||||
///
|
||||
WordList();
|
||||
///
|
||||
~WordList();
|
||||
|
||||
///
|
||||
docstring const & word(size_t idx) const;
|
||||
///
|
||||
@ -39,7 +35,7 @@ public:
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
Impl * d;
|
||||
std::unique_ptr<Impl> d;
|
||||
};
|
||||
|
||||
WordList * theWordList(std::string const & lang);
|
||||
|
@ -125,11 +125,11 @@ public:
|
||||
* If it isn't found, return an empty std::string.
|
||||
*/
|
||||
std::string const getPreambleDefByName(std::string const & name) const;
|
||||
/// noncopyable
|
||||
TemplateManager(TemplateManager const &) = delete;
|
||||
void operator=(TemplateManager const &) = delete;
|
||||
private:
|
||||
TemplateManager();
|
||||
/// noncopyable
|
||||
TemplateManager(TemplateManager const &);
|
||||
void operator=(TemplateManager const &);
|
||||
|
||||
void readTemplates(support::FileName const & path);
|
||||
void dumpTemplates(std::ostream &) const;
|
||||
|
@ -54,10 +54,11 @@ static const iconv_t invalid_cd = (iconv_t)(-1);
|
||||
|
||||
class IconvProcessor::Impl
|
||||
{
|
||||
// noncopyable because iconv_close() is called in destructor
|
||||
Impl(Impl const &);
|
||||
Impl & operator=(Impl const &);
|
||||
public:
|
||||
// noncopyable because iconv_close() is called in destructor
|
||||
Impl(Impl const &) = delete;
|
||||
Impl & operator=(Impl const &) = delete;
|
||||
|
||||
Impl(string const & to, string const & from)
|
||||
: cd(invalid_cd), tocode_(to), fromcode_(from)
|
||||
{}
|
||||
|
Loading…
Reference in New Issue
Block a user