Permalink
Browse files

Fix compilation with GCC 6

GCC 6 defaults to a newer C++ standard version.  C++11 introduced a new
overload for push_back so it is now sometimes necessary to specify which
overload is required.  C++11 also introduced std::bind so we need to
specify the namespace when using boost::lambda::bind.
  • Loading branch information...
1 parent fb8e8fe commit b5bd0370a569298d13b258ea4e57e48f5b03ecbf Jason Crain committed May 1, 2016
Showing with 35 additions and 19 deletions.
  1. +3 −1 MainWindow.cpp
  2. +18 −13 ProjectFilesDialog.cpp
  3. +2 −1 filters/page_split/PageLayoutEstimator.cpp
  4. +12 −4 tests/TestContentSpanFinder.cpp
View
@@ -1897,8 +1897,10 @@ MainWindow::showInsertFileDialog(BeforeOrAfter before_or_after, ImageId const& e
QFileInfo const file_info(files[i]);
ImageFileInfo image_file_info(file_info, std::vector<ImageMetadata>());
+ void (std::vector<ImageMetadata>::*push_back) (const ImageMetadata&) =
+ &std::vector<ImageMetadata>::push_back;
ImageMetadataLoader::Status const status = ImageMetadataLoader::load(
- files.at(i), boost::lambda::bind(&std::vector<ImageMetadata>::push_back,
+ files.at(i), boost::lambda::bind(push_back,
boost::ref(image_file_info.imageInfo()), boost::lambda::_1)
);
@@ -279,7 +279,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(boost::lambda::bind(&pushFileInfo<Item>, boost::ref(files), _1));
std::sort(files.begin(), files.end(), imageFileInfoLess);
@@ -419,8 +419,10 @@ ProjectFilesDialog::setInputDir(QString const& dir, bool const auto_add_files)
std::vector<QFileInfo> new_files(files.begin(), files.end());
std::vector<QFileInfo> existing_files;
+ void (std::vector<QFileInfo>::*push_back) (const QFileInfo&) =
+ &std::vector<QFileInfo>::push_back;
m_ptrInProjectFiles->files(
- bind(&std::vector<QFileInfo>::push_back, var(existing_files), _1)
+ boost::lambda::bind(push_back, var(existing_files), _1)
);
std::sort(new_files.begin(), new_files.end(), FileInfoLess());
std::sort(existing_files.begin(), existing_files.end(), FileInfoLess());
@@ -437,7 +439,7 @@ ProjectFilesDialog::setInputDir(QString const& dir, bool const auto_add_files)
ItemList items;
std::for_each(
files.begin(), files.end(),
- bind(
+ boost::lambda::bind(
&pushItemWithFlags<Item, ItemList>,
_1, boost::ref(items), cref(m_supportedExtensions)
)
@@ -471,7 +473,8 @@ ProjectFilesDialog::addToProject()
typedef std::vector<Item> ItemList;
ItemList items;
- m_ptrOffProjectFiles->items(selection, bind(&ItemList::push_back, var(items), _1));
+ void (ItemList::*push_back) (const Item&) = &ItemList::push_back;
+ m_ptrOffProjectFiles->items(selection, boost::lambda::bind(push_back, var(items), _1));
m_ptrInProjectFiles->append(items.begin(), items.end());
m_ptrOffProjectFiles->remove(selection);
@@ -508,7 +511,7 @@ ProjectFilesDialog::removeFromProject()
ItemList items;
m_ptrInProjectFiles->items(
- selection, bind(
+ selection, boost::lambda::bind(
&pushItemIfSameDir<Item, ItemList>,
boost::ref(items), _1, cref(input_dir)
)
@@ -691,10 +694,10 @@ ProjectFilesDialog::FileList::remove(QItemSelection const& selection)
std::transform(
selection.begin(), selection.end(),
std::back_inserter(sorted_ranges),
- bind(
+ boost::lambda::bind(
constructor<Range>(),
- bind(&QItemSelectionRange::top, _1),
- bind(&QItemSelectionRange::bottom, _1)
+ boost::lambda::bind(&QItemSelectionRange::top, _1),
+ boost::lambda::bind(&QItemSelectionRange::bottom, _1)
)
);
@@ -703,7 +706,8 @@ ProjectFilesDialog::FileList::remove(QItemSelection const& selection)
std::sort(
sorted_ranges.begin(), sorted_ranges.end(),
- bind((IntMemPtr)&Range::first, _1) < bind((IntMemPtr)&Range::first, _2)
+ boost::lambda::bind((IntMemPtr)&Range::first, _1) <
+ boost::lambda::bind((IntMemPtr)&Range::first, _2)
);
QVectorIterator<Range> it(sorted_ranges);
@@ -765,7 +769,7 @@ ProjectFilesDialog::FileList::prepareForLoadingFiles()
std::sort(
item_indexes.begin(), item_indexes.end(),
- bind(
+ boost::lambda::bind(
&ItemVisualOrdering::operator(), ItemVisualOrdering(),
var(m_items)[_1], var(m_items)[_2]
)
@@ -787,10 +791,11 @@ ProjectFilesDialog::FileList::loadNextFile()
Item& item = m_items[item_idx];
std::vector<ImageMetadata> per_page_metadata;
QString const file_path(item.fileInfo().absoluteFilePath());
+ void (std::vector<ImageMetadata>::*push_back) (const ImageMetadata&) =
+ &std::vector<ImageMetadata>::push_back;
ImageMetadataLoader::Status const st = ImageMetadataLoader::load(
- file_path, bind(
- &std::vector<ImageMetadata>::push_back,
- var(per_page_metadata), _1
+ file_path, boost::lambda::bind(
+ push_back, var(per_page_metadata), _1
)
);
@@ -523,7 +523,8 @@ 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));
+ void (std::deque<Span>::*push_back) (const Span&) = &std::deque<Span>::push_back;
+ span_finder.find(hist, boost::lambda::bind(push_back, var(spans), _1));
if (dbg) {
visualizeSpans(*dbg, spans, input, "spans");
@@ -37,9 +37,11 @@ BOOST_AUTO_TEST_CASE(test_empty_input)
ContentSpanFinder span_finder;
std::vector<Span> spans;
+ void (std::vector<Span>::*push_back) (const Span&) =
+ &std::vector<Span>::push_back;
span_finder.find(
SlicedHistogram(),
- bind(&std::vector<Span>::push_back, var(spans), _1)
+ boost::lambda::bind(push_back, var(spans), _1)
);
BOOST_CHECK(spans.empty());
@@ -63,7 +65,9 @@ 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));
+ void (std::vector<Span>::*push_back) (const Span&) =
+ &std::vector<Span>::push_back;
+ span_finder.find(hist, boost::lambda::bind(push_back, var(spans), _1));
BOOST_REQUIRE(spans.size() == 2);
BOOST_REQUIRE(spans[0] == Span(3, 3+3));
@@ -88,7 +92,9 @@ 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));
+ void (std::vector<Span>::*push_back) (const Span&) =
+ &std::vector<Span>::push_back;
+ span_finder.find(hist, boost::lambda::bind(push_back, var(spans), _1));
BOOST_REQUIRE(spans.size() == 2);
BOOST_REQUIRE(spans[0] == Span(1, 1+4));
@@ -114,7 +120,9 @@ 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));
+ void (std::vector<Span>::*push_back) (const Span&) =
+ &std::vector<Span>::push_back;
+ span_finder.find(hist, boost::lambda::bind(push_back, var(spans), _1));
// 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

0 comments on commit b5bd037

Please sign in to comment.