Simplifications, mainly removal of boost::function and useless std::bind

This commit is contained in:
Guillaume Munch 2016-06-29 10:22:13 +01:00
parent bc1672f6a0
commit 489dca71cd
16 changed files with 47 additions and 75 deletions

View File

@ -2218,8 +2218,8 @@ void Buffer::validate(LaTeXFeatures & features) const
if (!features.runparams().is_child)
params().validate(features);
for_each(paragraphs().begin(), paragraphs().end(),
bind(&Paragraph::validate, _1, ref(features)));
for (Paragraph const & p : paragraphs())
p.validate(features);
if (lyxerr.debugging(Debug::LATEX)) {
features.showStruct();

View File

@ -687,7 +687,7 @@ private:
ExportStatus doExport(std::string const & target, bool put_in_tempdir,
bool includeall, std::string & result_file) const;
///
ExportStatus preview(std::string const & format, bool includeall = false) const;
ExportStatus preview(std::string const & format, bool includeall) const;
///
void setMathFlavor(OutputParams & op) const;

View File

@ -32,10 +32,8 @@
#include "support/Package.h"
#include "support/lassert.h"
#include "support/bind.h"
#include <algorithm>
#include <functional>
#include <iterator>
#include <memory>
@ -277,55 +275,34 @@ bool BufferList::isOthersChild(Buffer * parent, Buffer * child)
Buffer const * parent_ = child->parent();
if (parent_ && parent_ != parent)
return true;
BufferStorage::iterator it = bstore.begin();
BufferStorage::iterator end = bstore.end();
for (; it != end; ++it) {
Buffer * buf = *it;
for(Buffer * buf : bstore)
if (buf != parent && buf->isChild(child))
return true;
}
return false;
}
namespace {
struct equivalent_to : public binary_function<FileName, FileName, bool>
{
bool operator()(FileName const & x, FileName const & y) const
{ return equivalent(x, y); }
};
}
Buffer * BufferList::getBuffer(support::FileName const & fname, bool internal) const
{
// 1) cheap test, using string comparison of file names
BufferStorage::const_iterator it = find_if(bstore.begin(), bstore.end(),
lyx::bind(equal_to<FileName>(), lyx::bind(&Buffer::fileName, _1), fname));
if (it != bstore.end())
return *it;
for (Buffer * b : bstore)
if (b->fileName() == fname)
return b;
// 2) possibly expensive test, using equivalence test of file names
it = find_if(bstore.begin(), bstore.end(),
lyx::bind(equivalent_to(), lyx::bind(&Buffer::fileName, _1), fname));
if (it != bstore.end())
return *it;
for (Buffer * b : bstore)
if (equivalent(b->fileName(), fname))
return b;
if (internal) {
// 1) cheap test, using string comparison of file names
BufferStorage::const_iterator it = find_if(binternal.begin(), binternal.end(),
lyx::bind(equal_to<FileName>(), lyx::bind(&Buffer::fileName, _1), fname));
if (it != binternal.end())
return *it;
for (Buffer * b : binternal)
if (b->fileName() == fname)
return b;
// 2) possibly expensive test, using equivalence test of file names
it = find_if(binternal.begin(), binternal.end(),
lyx::bind(equivalent_to(), lyx::bind(&Buffer::fileName, _1), fname));
if (it != binternal.end())
return *it;
for (Buffer * b : binternal)
if (equivalent(b->fileName(), fname))
return b;
}
return 0;
}

View File

@ -51,8 +51,6 @@
#include "mathed/MathData.h"
#include "mathed/MathMacro.h"
#include "support/bind.h"
#include <sstream>
#include <limits>
#include <map>
@ -1184,9 +1182,8 @@ void Cursor::plainInsert(MathAtom const & t)
void Cursor::insert(docstring const & str)
{
for_each(str.begin(), str.end(),
bind(static_cast<void(Cursor::*)(char_type)>
(&Cursor::insert), this, _1));
for (char_type c : str)
insert(c);
}

View File

@ -27,7 +27,6 @@
#include "support/lassert.h"
#include "support/lstrings.h"
#include "support/bind.h"
#include "support/regex.h"
#include "support/TempFile.h"

View File

@ -50,7 +50,6 @@
#include "frontends/alert.h"
#include "frontends/Application.h"
#include "support/bind.h"
#include "support/ConsoleApplication.h"
#include "support/lassert.h"
#include "support/debug.h"
@ -65,8 +64,9 @@
#include "support/unique_ptr.h"
#include <algorithm>
#include <iostream>
#include <csignal>
#include <iostream>
#include <functional>
#include <map>
#include <stdlib.h>
#include <string>
@ -492,9 +492,8 @@ int LyX::execWithoutGui(int & argc, char * argv[])
LYXERR(Debug::FILES, "Loading " << fname);
if (buf && buf->loadLyXFile() == Buffer::ReadSuccess) {
ErrorList const & el = buf->errorList("Parse");
if (!el.empty())
for_each(el.begin(), el.end(),
bind(&LyX::printError, this, _1));
for(ErrorItem const & e : el)
printError(e);
command_line_buffers.push_back(buf);
} else {
if (buf)
@ -1109,7 +1108,7 @@ bool LyX::readEncodingsFile(string const & enc_name,
namespace {
/// return the the number of arguments consumed
typedef boost::function<int(string const &, string const &, string &)> cmd_helper;
typedef function<int(string const &, string const &, string &)> cmd_helper;
int parse_dbg(string const & arg, string const &, string &)
{

View File

@ -47,7 +47,6 @@
#include "support/lstrings.h"
#include "support/textutils.h"
#include "support/bind.h"
#include <boost/crc.hpp>
#include <algorithm>

View File

@ -26,11 +26,13 @@
#include "support/debug.h"
#include "support/environment.h"
#include "support/FileName.h"
#include "support/lassert.h"
#include "support/socktools.h"
#include "support/bind.h"
#include <boost/assert.hpp>
#include <cerrno>
#include <cstring>
#include <ostream>
#if defined (_WIN32)

View File

@ -18,7 +18,7 @@
#include "support/strfwd.h"
#include <boost/function.hpp>
#include <functional>
#include <vector>
@ -216,12 +216,12 @@ public:
* passing Color_white returns "ffffff".
*/
virtual std::string const hexName(ColorCode col) = 0;
/**
* add a callback for socket read notification
* @param fd socket descriptor (file/socket/etc)
*/
typedef boost::function<void()> SocketCallback;
typedef std::function<void()> SocketCallback;
virtual void registerSocketCallback(int fd, SocketCallback func) = 0;
/**

View File

@ -146,7 +146,6 @@
#include <QMacPasteboardMime>
#endif // Q_OS_MAC
#include "support/bind.h"
#include <boost/crc.hpp>
#include <exception>

View File

@ -23,8 +23,6 @@
#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/bind.h"
#include <algorithm>
using namespace std;

View File

@ -26,6 +26,7 @@
#include "support/filetools.h"
#include "support/FileMonitor.h"
#include "support/lassert.h"
#include "support/unique_ptr.h"
#include "support/bind.h"
#include "support/TempFile.h"
@ -437,7 +438,8 @@ void CacheItem::Impl::convertToDisplayFormat()
// Connect a signal to this->imageConverted and pass this signal to
// the graphics converter so that we can load the modified file
// on completion of the conversion process.
converter_.reset(new Converter(filename, to_file_base.absFileName(), from, to_));
converter_ = make_unique<Converter>(filename, to_file_base.absFileName(),
from, to_);
converter_->connect(bind(&Impl::imageConverted, this, _1));
converter_->startConversion();
}

View File

@ -338,7 +338,7 @@ void extractIt(boost::any const & any_factory,
return;
Factory factory = boost::any_cast<Factory>(any_factory);
if (!factory.empty())
if (!factory)
transformer = factory(data);
}

View File

@ -19,11 +19,12 @@
#include "support/unique_ptr.h"
#include <boost/any.hpp>
#include <boost/function.hpp>
#include <string>
#include <functional>
#include <map>
#include <memory>
#include <string>
namespace lyx {
@ -317,17 +318,17 @@ enum TransformID {
};
typedef boost::function<TransformOption::ptr_type(ClipData)>
typedef std::function<TransformOption::ptr_type(ClipData)>
ClipOptionFactory;
typedef boost::function<TransformOption::ptr_type(std::string)>
typedef std::function<TransformOption::ptr_type(std::string)>
ExtraOptionFactory;
typedef boost::function<TransformOption::ptr_type(ResizeData)>
typedef std::function<TransformOption::ptr_type(ResizeData)>
ResizeOptionFactory;
typedef boost::function<TransformOption::ptr_type(RotationData)>
typedef std::function<TransformOption::ptr_type(RotationData)>
RotationOptionFactory;
typedef boost::function<TransformCommand::ptr_type(ResizeData)>
typedef std::function<TransformCommand::ptr_type(ResizeData)>
ResizeCommandFactory;
typedef boost::function<TransformCommand::ptr_type(RotationData)>
typedef std::function<TransformCommand::ptr_type(RotationData)>
RotationCommandFactory;

View File

@ -423,8 +423,8 @@ void InsetText::rejectChanges()
void InsetText::validate(LaTeXFeatures & features) const
{
features.useInsetLayout(getLayout());
for_each(paragraphs().begin(), paragraphs().end(),
bind(&Paragraph::validate, _1, ref(features)));
for (Paragraph const & p : paragraphs())
p.validate(features);
}

View File

@ -47,7 +47,6 @@
using namespace std;
namespace lyx {
namespace support {
@ -475,7 +474,7 @@ void callNext()
Process pro = callQueue_.front();
callQueue_.pop();
// Bind our chain caller
pro.second->connect(lyx::bind(&ForkedCallQueue::callback, _1, _2));
pro.second->connect(callback);
ForkedCall call;
//If we fail to fork the process, then emit the signal
//to tell the outside world that it failed.
@ -553,7 +552,7 @@ string const getChildErrorMessage()
namespace ForkedCallsController {
typedef std::shared_ptr<ForkedProcess> ForkedProcessPtr;
typedef shared_ptr<ForkedProcess> ForkedProcessPtr;
typedef list<ForkedProcessPtr> ListType;
typedef ListType::iterator iterator;