commit 489dca71cd99bbc78780fa40311a2eb042c0320e
Author: Guillaume Munch <[email protected]>
Date: Wed Jun 29 10:22:13 2016 +0100
Simplifications, mainly removal of boost::function and useless std::bind
---
src/Buffer.cpp | 4 +-
src/Buffer.h | 2 +-
src/BufferList.cpp | 51 +++++++++------------------------
src/Cursor.cpp | 7 +---
src/LayoutFile.cpp | 1 -
src/LyX.cpp | 11 +++----
src/ParagraphMetrics.cpp | 1 -
src/ServerSocket.cpp | 4 ++-
src/frontends/Application.h | 6 ++--
src/frontends/qt4/GuiApplication.cpp | 1 -
src/frontends/qt4/Toolbars.cpp | 2 -
src/graphics/GraphicsCacheItem.cpp | 4 ++-
src/insets/ExternalTransforms.cpp | 2 +-
src/insets/ExternalTransforms.h | 17 ++++++-----
src/insets/InsetText.cpp | 4 +-
src/support/ForkedCalls.cpp | 5 +--
16 files changed, 47 insertions(+), 75 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 12e3400..08f3148 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -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();
diff --git a/src/Buffer.h b/src/Buffer.h
index f488c4a..7acf1f3 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -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;
diff --git a/src/BufferList.cpp b/src/BufferList.cpp
index 9a5c4e1..0b76f13 100644
--- a/src/BufferList.cpp
+++ b/src/BufferList.cpp
@@ -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;
}
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index baf529b..2894f9d 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -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);
}
diff --git a/src/LayoutFile.cpp b/src/LayoutFile.cpp
index 8cca663..771a9c4 100644
--- a/src/LayoutFile.cpp
+++ b/src/LayoutFile.cpp
@@ -27,7 +27,6 @@
#include "support/lassert.h"
#include "support/lstrings.h"
-#include "support/bind.h"
#include "support/regex.h"
#include "support/TempFile.h"
diff --git a/src/LyX.cpp b/src/LyX.cpp
index 66ff6f3..a732c7e 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -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 &)
{
diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp
index 1fd248f..01db6cb 100644
--- a/src/ParagraphMetrics.cpp
+++ b/src/ParagraphMetrics.cpp
@@ -47,7 +47,6 @@
#include "support/lstrings.h"
#include "support/textutils.h"
-#include "support/bind.h"
#include <boost/crc.hpp>
#include <algorithm>
diff --git a/src/ServerSocket.cpp b/src/ServerSocket.cpp
index 72a70d4..ece3549 100644
--- a/src/ServerSocket.cpp
+++ b/src/ServerSocket.cpp
@@ -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)
diff --git a/src/frontends/Application.h b/src/frontends/Application.h
index df0be95..b321052 100644
--- a/src/frontends/Application.h
+++ b/src/frontends/Application.h
@@ -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;
/**
diff --git a/src/frontends/qt4/GuiApplication.cpp
b/src/frontends/qt4/GuiApplication.cpp
index eb8c305..074492b 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -146,7 +146,6 @@
#include <QMacPasteboardMime>
#endif // Q_OS_MAC
-#include "support/bind.h"
#include <boost/crc.hpp>
#include <exception>
diff --git a/src/frontends/qt4/Toolbars.cpp b/src/frontends/qt4/Toolbars.cpp
index 20eee93..19b9560 100644
--- a/src/frontends/qt4/Toolbars.cpp
+++ b/src/frontends/qt4/Toolbars.cpp
@@ -23,8 +23,6 @@
#include "support/gettext.h"
#include "support/lstrings.h"
-#include "support/bind.h"
-
#include <algorithm>
using namespace std;
diff --git a/src/graphics/GraphicsCacheItem.cpp
b/src/graphics/GraphicsCacheItem.cpp
index 1a7279c..ea59173 100644
--- a/src/graphics/GraphicsCacheItem.cpp
+++ b/src/graphics/GraphicsCacheItem.cpp
@@ -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();
}
diff --git a/src/insets/ExternalTransforms.cpp
b/src/insets/ExternalTransforms.cpp
index ee31e19..7ac41ab 100644
--- a/src/insets/ExternalTransforms.cpp
+++ b/src/insets/ExternalTransforms.cpp
@@ -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);
}
diff --git a/src/insets/ExternalTransforms.h b/src/insets/ExternalTransforms.h
index 1d81900..cd3e5e2 100644
--- a/src/insets/ExternalTransforms.h
+++ b/src/insets/ExternalTransforms.h
@@ -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;
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 5311527..216b9c9 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -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);
}
diff --git a/src/support/ForkedCalls.cpp b/src/support/ForkedCalls.cpp
index fc2b599..4827947 100644
--- a/src/support/ForkedCalls.cpp
+++ b/src/support/ForkedCalls.cpp
@@ -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;