Created
February 24, 2015 18:40
-
-
Save jkseppan/49901ece3da6a0604887 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/MainWindow.cpp b/MainWindow.cpp | |
index 4b383cc..f5ebe58 100644 | |
--- a/MainWindow.cpp | |
+++ b/MainWindow.cpp | |
@@ -1979,10 +1979,11 @@ MainWindow::showInsertFileDialog(BeforeOrAfter before_or_after, ImageId const& e | |
QFileInfo const file_info(files[i]); | |
ImageFileInfo image_file_info(file_info, std::vector<ImageMetadata>()); | |
- ImageMetadataLoader::Status const status = ImageMetadataLoader::load( | |
- files.at(i), bind(&std::vector<ImageMetadata>::push_back, | |
- boost::ref(image_file_info.imageInfo()), _1) | |
- ); | |
+ ImageMetadataLoader::Status const status = | |
+ ImageMetadataLoader::load(files.at(i), | |
+ [&] (const ImageMetadata& data) { | |
+ image_file_info.imageInfo().push_back(data); | |
+ }); | |
if (status == ImageMetadataLoader::LOADED) { | |
new_files.push_back(image_file_info); | |
diff --git a/ProjectFilesDialog.cpp b/ProjectFilesDialog.cpp | |
index 044b888..5173b7c 100644 | |
--- a/ProjectFilesDialog.cpp | |
+++ b/ProjectFilesDialog.cpp | |
@@ -285,8 +285,7 @@ ProjectFilesDialog::inProjectFiles() const | |
using namespace boost::lambda; | |
std::vector<ImageFileInfo> files; | |
- m_ptrInProjectFiles->items(bind(&pushFileInfo<Item>, boost::ref(files), _1)); | |
- | |
+ m_ptrInProjectFiles->items([&] (const Item& info) { pushFileInfo(files, info); }); | |
std::sort(files.begin(), files.end(), imageFileInfoLess); | |
return files; | |
@@ -425,9 +424,7 @@ ProjectFilesDialog::setInputDir(QString const& dir, bool const auto_add_files) | |
std::vector<QFileInfo> new_files(files.begin(), files.end()); | |
std::vector<QFileInfo> existing_files; | |
- m_ptrInProjectFiles->files( | |
- bind(&std::vector<QFileInfo>::push_back, var(existing_files), _1) | |
- ); | |
+ m_ptrInProjectFiles->files([&] (const QFileInfo& info) { existing_files.push_back(info); }); | |
std::sort(new_files.begin(), new_files.end(), FileInfoLess()); | |
std::sort(existing_files.begin(), existing_files.end(), FileInfoLess()); | |
@@ -441,13 +438,8 @@ ProjectFilesDialog::setInputDir(QString const& dir, bool const auto_add_files) | |
typedef std::vector<Item> ItemList; | |
ItemList items; | |
- std::for_each( | |
- files.begin(), files.end(), | |
- bind( | |
- &pushItemWithFlags<Item, ItemList>, | |
- _1, boost::ref(items), cref(m_supportedExtensions) | |
- ) | |
- ); | |
+ std::for_each(files.begin(), files.end(), | |
+ [&] (const QFileInfo& info) { pushItemWithFlags<Item>(info, items, m_supportedExtensions); }); | |
m_ptrOffProjectFiles->assign(items.begin(), items.end()); | |
@@ -477,7 +469,7 @@ ProjectFilesDialog::addToProject() | |
typedef std::vector<Item> ItemList; | |
ItemList items; | |
- m_ptrOffProjectFiles->items(selection, bind(&ItemList::push_back, var(items), _1)); | |
+ m_ptrOffProjectFiles->items(selection, [&] (const Item& item) { items.push_back(item); }); | |
m_ptrInProjectFiles->append(items.begin(), items.end()); | |
m_ptrOffProjectFiles->remove(selection); | |
@@ -513,12 +505,9 @@ ProjectFilesDialog::removeFromProject() | |
typedef std::vector<Item> ItemList; | |
ItemList items; | |
- m_ptrInProjectFiles->items( | |
- selection, bind( | |
- &pushItemIfSameDir<Item, ItemList>, | |
- boost::ref(items), _1, cref(input_dir) | |
- ) | |
- ); | |
+ m_ptrInProjectFiles->items(selection, | |
+ [&] (const Item& item) { | |
+ pushItemIfSameDir<Item, ItemList>(items, item, input_dir); }); | |
m_ptrOffProjectFiles->append(items.begin(), items.end()); | |
m_ptrInProjectFiles->remove(selection); | |
@@ -697,20 +686,16 @@ ProjectFilesDialog::FileList::remove(QItemSelection const& selection) | |
std::transform( | |
selection.begin(), selection.end(), | |
std::back_inserter(sorted_ranges), | |
- bind( | |
- constructor<Range>(), | |
- bind(&QItemSelectionRange::top, _1), | |
- bind(&QItemSelectionRange::bottom, _1) | |
- ) | |
+ [&] (const QItemSelectionRange& range) { | |
+ return Range(range.top(), range.bottom()); | |
+ } | |
); | |
// This hack is required to make it build with boost 1.44. | |
typedef int const Range::* IntMemPtr; | |
- std::sort( | |
- sorted_ranges.begin(), sorted_ranges.end(), | |
- bind((IntMemPtr)&Range::first, _1) < bind((IntMemPtr)&Range::first, _2) | |
- ); | |
+ std::sort(sorted_ranges.begin(), sorted_ranges.end(), | |
+ [] (const Range& a, const Range& b) { return a < b; }); | |
QVectorIterator<Range> it(sorted_ranges); | |
int rows_removed = 0; | |
@@ -768,15 +753,11 @@ ProjectFilesDialog::FileList::prepareForLoadingFiles() | |
for (int i = 0; i < num_items; ++i) { | |
item_indexes.push_back(i); | |
} | |
- | |
- std::sort( | |
- item_indexes.begin(), item_indexes.end(), | |
- bind( | |
- &ItemVisualOrdering::operator(), ItemVisualOrdering(), | |
- var(m_items)[_1], var(m_items)[_2] | |
- ) | |
- ); | |
- | |
+ | |
+ ItemVisualOrdering ivo; | |
+ std::sort(item_indexes.begin(), item_indexes.end(), | |
+ [&] (size_t a, size_t b) { return ivo(m_items[a], m_items[b]); }); | |
+ | |
m_itemsToLoad.swap(item_indexes); | |
} | |
@@ -793,12 +774,9 @@ ProjectFilesDialog::FileList::loadNextFile() | |
Item& item = m_items[item_idx]; | |
std::vector<ImageMetadata> per_page_metadata; | |
QString const file_path(item.fileInfo().absoluteFilePath()); | |
- ImageMetadataLoader::Status const st = ImageMetadataLoader::load( | |
- file_path, bind( | |
- &std::vector<ImageMetadata>::push_back, | |
- var(per_page_metadata), _1 | |
- ) | |
- ); | |
+ ImageMetadataLoader::Status const st = | |
+ ImageMetadataLoader::load | |
+ (file_path, [&] (const ImageMetadata& data) { per_page_metadata.push_back(data); }); | |
LoadStatus status; | |
diff --git a/filters/page_split/PageLayoutEstimator.cpp b/filters/page_split/PageLayoutEstimator.cpp | |
index 8274e2a..b5f033b 100644 | |
--- a/filters/page_split/PageLayoutEstimator.cpp | |
+++ b/filters/page_split/PageLayoutEstimator.cpp | |
@@ -527,7 +527,7 @@ PageLayoutEstimator::cutAtWhitespaceDeskewed150( | |
std::deque<Span> spans; | |
SlicedHistogram hist(cc_img, SlicedHistogram::COLS); | |
- span_finder.find(hist, bind(&std::deque<Span>::push_back, var(spans), _1)); | |
+ span_finder.find(hist, [&] (const Span& span) { spans.push_back(span); }); | |
if (dbg) { | |
visualizeSpans(*dbg, spans, input, "spans"); | |
diff --git a/tests/TestContentSpanFinder.cpp b/tests/TestContentSpanFinder.cpp | |
index 9df1be2..87e444b 100644 | |
--- a/tests/TestContentSpanFinder.cpp | |
+++ b/tests/TestContentSpanFinder.cpp | |
@@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(test_empty_input) | |
std::vector<Span> spans; | |
span_finder.find( | |
SlicedHistogram(), | |
- bind(&std::vector<Span>::push_back, var(spans), _1) | |
+ [&] (const Span& span) { spans.push_back(span); } | |
); | |
BOOST_CHECK(spans.empty()); | |
@@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(test_min_content_width) | |
span_finder.setMinContentWidth(2); | |
std::vector<Span> spans; | |
- span_finder.find(hist, bind(&std::vector<Span>::push_back, var(spans), _1)); | |
+ span_finder.find(hist, [&] (const Span& span) { spans.push_back(span); }); | |
BOOST_REQUIRE(spans.size() == 2); | |
BOOST_REQUIRE(spans[0] == Span(3, 3+3)); | |
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(test_min_whitespace_width) | |
span_finder.setMinWhitespaceWidth(2); | |
std::vector<Span> spans; | |
- span_finder.find(hist, bind(&std::vector<Span>::push_back, var(spans), _1)); | |
+ span_finder.find(hist, [&] (const Span& span) { spans.push_back(span); }); | |
BOOST_REQUIRE(spans.size() == 2); | |
BOOST_REQUIRE(spans[0] == Span(1, 1+4)); | |
@@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(test_min_content_and_whitespace_width) | |
span_finder.setMinWhitespaceWidth(2); | |
std::vector<Span> spans; | |
- span_finder.find(hist, bind(&std::vector<Span>::push_back, var(spans), _1)); | |
+ span_finder.find(hist, [&] (const Span& span) { spans.push_back(span); }); | |
// Note that although a content block at index 1 is too short, | |
// it's still allowed to merge with content at positions 3 and 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment