Remove boost::bind

This commit is contained in:
otakuto 2023-08-18 07:27:20 +09:00 committed by manongjohn
parent 6ea738cfc4
commit 37337aeaf4
9 changed files with 35 additions and 68 deletions

View file

@ -14,7 +14,6 @@
// Boost includes
#include <boost/iterator/counting_iterator.hpp>
#include <boost/bind.hpp>
//*******************************************************************************
// Local namespace stuff
@ -108,7 +107,7 @@ void getBoundaries(TVectorImage &vi, std::vector<int> &strokes) {
std::copy_if(boost::make_counting_iterator(0u),
boost::make_counting_iterator(vi.getStrokeCount()),
std::back_inserter(strokes),
boost::bind(locals::isBoundary, sData, _1));
[&](UINT e) { return locals::isBoundary(sData, e); });
}
} // namespace

View file

@ -24,9 +24,6 @@
// TnzCore includes
#include "drawutil.h"
// boost includes
#include <boost/bind.hpp>
using namespace ToolUtils;
using namespace DragSelectionTool;
@ -655,7 +652,7 @@ void DragSelectionTool::VectorDeformTool::transformWholeLevel() {
// Remove unwanted fids
fids.erase(std::remove_if(
fids.begin(), fids.end(),
boost::bind(::currentOrNotSelected, boost::cref(*tool), _1)),
[tool](const TFrameId &fid) { return currentOrNotSelected(*tool, fid); }),
fids.end());
TUndoManager::manager()->beginBlock();
@ -704,9 +701,9 @@ void DragSelectionTool::VectorDeformTool::transformWholeLevel() {
// Finally, notify changed frames
std::for_each(fids.begin(), fids.end(),
boost::bind( // NOTE: current frame is not here - it should be,
&TTool::notifyImageChanged, m_tool,
_1)); // but it's currently unnecessary, in fact...
// NOTE: current frame is not here - it should be,
// but it's currently unnecessary, in fact...
[this](const TFrameId &fid) { m_tool->notifyImageChanged(fid); });
// notifyImageChanged(fid) must be invoked OUTSIDE of the loop - since it
// seems to imply notifyImageChanged()
@ -976,12 +973,12 @@ void DragSelectionTool::VectorChangeThicknessTool::setStrokesThickness(
const std::set<int> &selectedStrokeIdxs = strokeSelection->getSelection();
std::for_each(selectedStrokeIdxs.begin(), selectedStrokeIdxs.end(),
boost::bind(locals::setThickness, boost::cref(data), _1));
[&data](int s) { locals::setThickness(data, s); });
} else {
std::vector<int> strokeIdxs = getSelectedStrokes(vi, levelSelection);
std::for_each(strokeIdxs.begin(), strokeIdxs.end(),
boost::bind(locals::setThickness, boost::cref(data), _1));
[&data](int s) { locals::setThickness(data, s); });
}
}
@ -1030,12 +1027,12 @@ void DragSelectionTool::VectorChangeThicknessTool::changeImageThickness(
const std::set<int> &selectedStrokeIdxs = strokeSelection->getSelection();
std::for_each(selectedStrokeIdxs.begin(), selectedStrokeIdxs.end(),
boost::bind(locals::changeThickness, boost::ref(data), _1));
[&data](int s) { locals::changeThickness(data, s); });
} else {
std::vector<int> strokeIdxs = getSelectedStrokes(vi, levelSelection);
std::for_each(strokeIdxs.begin(), strokeIdxs.end(),
boost::bind(locals::changeThickness, boost::ref(data), _1));
[&data](int s) { locals::changeThickness(data, s); });
}
}
@ -1061,8 +1058,7 @@ void DragSelectionTool::VectorChangeThicknessTool::addUndo() {
// Remove unwanted frames
fids.erase(std::remove_if(fids.begin(), fids.end(),
boost::bind(::currentOrNotSelected,
boost::cref(*vtool), _1)),
[vtool](const TFrameId &fid) { return currentOrNotSelected(*vtool, fid); }),
fids.end());
TUndoManager::manager()->beginBlock();
@ -1098,9 +1094,7 @@ void DragSelectionTool::VectorChangeThicknessTool::addUndo() {
// Finally, notify changed frames
std::for_each(fids.begin(), fids.end(),
boost::bind( // NOTE: current frame is not here - it was
&TTool::notifyImageChanged, m_tool,
_1)); // aldready notified
[this](const TFrameId &fid) { m_tool->notifyImageChanged(fid); });
} else
TUndoManager::manager()->add(m_undo.release()); // Outside any undo block
}
@ -1286,7 +1280,7 @@ void VectorSelectionTool::setNewFreeDeformer() {
fids.erase(std::remove_if(
fids.begin(), fids.end(),
boost::bind(::currentOrNotSelected, boost::cref(*this), _1)),
[this](const TFrameId &fid) { return currentOrNotSelected(*this, fid); }),
fids.end());
std::vector<TFrameId>::iterator ft, fEnd = fids.end();

View file

@ -80,7 +80,6 @@
#include "tcg/boost/permuted_range.h"
// boost includes
#include <boost/bind.hpp>
#include <boost/iterator/counting_iterator.hpp>
#include <boost/range/adaptor/filtered.hpp>
#include <boost/range/adaptor/transformed.hpp>
@ -435,7 +434,7 @@ void FileBrowser::sortByDataModel(DataType dataType, bool isDiscendent) {
std::stable_sort(
new2OldIdx.begin(), new2OldIdx.end(),
boost::bind(locals::itemLess, _1, _2, boost::ref(*this), dataType));
[this, dataType](int x, int y) { return locals::itemLess(x, y, *this, dataType); });
// Use the renumbering table to permutate elements
std::vector<Item>(
@ -453,15 +452,13 @@ void FileBrowser::sortByDataModel(DataType dataType, bool isDiscendent) {
boost::make_counting_iterator(int(m_items.size())));
std::sort(old2NewIdx.begin(), old2NewIdx.end(),
boost::bind(locals::indexLess, _1, _2, boost::ref(new2OldIdx)));
[&new2OldIdx](int aIdx, int bIdx){ return locals::indexLess(aIdx, bIdx, new2OldIdx); });
std::vector<int> newSelectedIndices;
tcg::substitute(
newSelectedIndices,
tcg::permuted_range(old2NewIdx, fs->getSelectedIndices() |
ba::filtered(boost::bind(
std::less<int>(), _1,
int(old2NewIdx.size())))));
ba::filtered([&old2NewIdx](int x){ return x < old2NewIdx.size(); })));
fs->select(!newSelectedIndices.empty() ? &newSelectedIndices.front() : 0,
int(newSelectedIndices.size()));
@ -486,8 +483,8 @@ void FileBrowser::sortByDataModel(DataType dataType, bool isDiscendent) {
tcg::substitute(
newSelectedIndices,
fs->getSelectedIndices() |
ba::filtered(boost::bind(std::less<int>(), _1, iCount)) |
ba::transformed(boost::bind(locals::complement, _1, lastIdx)));
ba::filtered([iCount](int x){ return x < iCount; }) |
ba::transformed([lastIdx](int x){ return locals::complement(x, lastIdx); }));
fs->select(!newSelectedIndices.empty() ? &newSelectedIndices.front() : 0,
int(newSelectedIndices.size()));

View file

@ -35,8 +35,6 @@
#include <boost/operators.hpp>
#include <boost/range.hpp>
#include <boost/bind.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/range/algorithm/for_each.hpp>
@ -239,9 +237,7 @@ struct buildResources_locals {
const MergeData *mdt,
*mdEnd = mergeTable + boost::size(mergeTable) - 1; // Last item is fake
mdt = std::find_if(mergeTable, mdEnd,
boost::bind(exactMatch<MergeData>, _1,
boost::cref(rt->first.first.m_relFp)));
mdt = std::find_if(mergeTable, mdEnd, [&rt](const MergeData& mergeData){ return exactMatch(mergeData, rt->first.first.m_relFp); });
if (mdt != mdEnd) {
// Lookup every possible resource component to merge
@ -306,8 +302,7 @@ void buildResources(std::vector<Resource> &resources, const TFilePath &rootPath,
const FormatData *fdt,
*fdEnd = l_formatDatas + boost::size(l_formatDatas);
fdt = std::find_if(
l_formatDatas, fdEnd,
boost::bind(exactMatch<FormatData>, _1, boost::cref(relPath)));
l_formatDatas, fdEnd, [&relPath](const FormatData &formatData){ return exactMatch(formatData, relPath); });
if (fdt != fdEnd) {
relPath = fdt->m_resourcePathFunc(relPath);
@ -402,8 +397,7 @@ struct import_Locals {
// Perform resource copy
std::for_each(rsrc.m_components.begin(), rsrc.m_components.end(),
boost::bind(copy, boost::cref(srcDir), boost::cref(dstDir),
_1, overwrite));
[&srcDir, &dstDir, &overwrite](const Resource::Component &comp){ copy(srcDir, dstDir, comp, overwrite); });
} catch (const TException &e) {
DVGui::error(QString::fromStdWString(e.getMessage()));
} catch (...) {
@ -492,7 +486,7 @@ QString OverwriteDialog::acceptResolution(void *obj_, int resolution,
static bool existsResource(const TFilePath &dstDir, const Resource &rsrc) {
return std::any_of(rsrc.m_components.begin(), rsrc.m_components.end(),
boost::bind(existsComponent, boost::cref(dstDir), _1));
[&dstDir](const Resource::Component &comp){ return existsComponent(dstDir, comp); });
}
}; // locals
@ -547,7 +541,7 @@ int IoCmd::loadResourceFolders(LoadResourceArguments &args,
{
if (std::any_of(
args.resourceDatas.begin(), args.resourceDatas.end(),
boost::bind(locals::isExternPath, boost::cref(*scene), _1))) {
[scene](const LRArgs::ResourceData &rd){ return locals::isExternPath(*scene, rd); })) {
// Ask for data import in this case
int resolutionButton = DVGui::MsgBox(
QObject::tr("Selected folders don't belong to the current project.\n"
@ -570,11 +564,8 @@ int IoCmd::loadResourceFolders(LoadResourceArguments &args,
// Select resources to be loaded
std::vector<Resource> resources;
boost::for_each(
args.resourceDatas |
boost::adaptors::transformed(boost::bind<const TFilePath &>(
&LRArgs::ResourceData::m_path, _1)),
boost::bind(::buildResources, boost::ref(resources), _1, TFilePath()));
boost::for_each(args.resourceDatas,
[&resources](const LRArgs::ResourceData &resourceData){ buildResources(resources, resourceData.m_path, TFilePath()); });
// Import them if required
if (import) ::import(*scene, resources, *sb);

View file

@ -81,7 +81,6 @@
#include "tcg/boost/permuted_range.h"
// boost includes
#include <boost/bind.hpp>
#include <boost/iterator/counting_iterator.hpp>
#include <boost/range/adaptor/filtered.hpp>
#include <boost/range/adaptor/transformed.hpp>
@ -419,7 +418,7 @@ void SceneBrowser::sortByDataModel(DataType dataType, bool isDiscendent) {
std::stable_sort(
new2OldIdx.begin(), new2OldIdx.end(),
boost::bind(locals::itemLess, _1, _2, boost::ref(*this), dataType));
[this, dataType](int x, int y){ return locals::itemLess(x, y, *this, dataType); });
// Use the renumbering table to permutate elements
std::vector<Item>(
@ -437,15 +436,13 @@ void SceneBrowser::sortByDataModel(DataType dataType, bool isDiscendent) {
boost::make_counting_iterator(int(m_items.size())));
std::sort(old2NewIdx.begin(), old2NewIdx.end(),
boost::bind(locals::indexLess, _1, _2, boost::ref(new2OldIdx)));
[&new2OldIdx](int x, int y){ return locals::indexLess(x, y, new2OldIdx); });
std::vector<int> newSelectedIndices;
tcg::substitute(
newSelectedIndices,
tcg::permuted_range(old2NewIdx, fs->getSelectedIndices() |
ba::filtered(boost::bind(
std::less<int>(), _1,
int(old2NewIdx.size())))));
ba::filtered([&old2NewIdx](int x){ return x < old2NewIdx.size(); })));
fs->select(!newSelectedIndices.empty() ? &newSelectedIndices.front() : 0,
int(newSelectedIndices.size()));
@ -470,8 +467,8 @@ void SceneBrowser::sortByDataModel(DataType dataType, bool isDiscendent) {
tcg::substitute(
newSelectedIndices,
fs->getSelectedIndices() |
ba::filtered(boost::bind(std::less<int>(), _1, iCount)) |
ba::transformed(boost::bind(locals::complement, _1, lastIdx)));
ba::filtered([iCount](int x){ return x < iCount; }) |
ba::transformed([lastIdx](int x){ return locals::complement(x, lastIdx); }));
fs->select(!newSelectedIndices.empty() ? &newSelectedIndices.front() : 0,
int(newSelectedIndices.size()));

View file

@ -24,7 +24,6 @@
#include "tcg/boost/range_utility.h"
// Boost includes
#include <boost/bind.hpp>
#include <boost/range/counting_range.hpp>
#include <boost/range/adaptor/transformed.hpp>
@ -63,8 +62,7 @@ void getSelectedFrames<TXshSimpleLevel>(
if (!sl) continue;
tcg::substitute(frames[sl], boost::counting_range(0, sl->getFrameCount()) |
boost::adaptors::transformed(boost::bind(
&TXshSimpleLevel::getFrameId, sl, _1)));
boost::adaptors::transformed([&sl](int index){ return sl->getFrameId(index); }));
}
}

View file

@ -72,8 +72,6 @@
#include "tcg/boost/range_utility.h"
// boost includes
#include <boost/bind.hpp>
#include <boost/bind/make_adaptable.hpp>
#include <boost/range/adaptor/filtered.hpp>
#include <boost/range/adaptor/transformed.hpp>
@ -506,8 +504,7 @@ public:
: GlobalKeyframeUndo(frame) {
tcg::substitute(
m_columns,
columns | ba::filtered(std::not1(boost::make_adaptable<bool, int>(
boost::bind(isKeyframe, frame, _1)))));
columns | ba::filtered([frame](int c){ return !isKeyframe(frame, c); }));
}
void redo() const override {
@ -581,11 +578,10 @@ public:
}; // locals
tcg::substitute(m_columns,
columns | ba::filtered(boost::bind(isKeyframe, frame, _1)));
columns | ba::filtered([frame](int c){ return isKeyframe(frame, c); }));
tcg::substitute(m_keyframes,
m_columns | ba::transformed(boost::bind(locals::getKeyframe,
frame, _1)));
m_columns | ba::transformed([frame](int c){ return locals::getKeyframe(frame, c); }));
}
void redo() const override {

View file

@ -39,7 +39,6 @@
#include "tcg/boost/range_utility.h"
// boost includes
#include <boost/bind.hpp>
#include <boost/range/counting_range.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/adaptor/filtered.hpp>
@ -585,8 +584,7 @@ void PaletteCmd::eraseStyles(const std::set<TXshSimpleLevel *> &levels,
tcg::substitute(
levelImages.second,
boost::counting_range(0, levelImages.first->getFrameCount()) |
boost::adaptors::transformed(boost::bind(
cloneImage, boost::cref(*levelImages.first), _1)));
boost::adaptors::transformed([&levelImages](int f){ return cloneImage(*levelImages.first, f); }));
}
static void restoreImage(const TXshSimpleLevelP &level, int f,

View file

@ -28,9 +28,6 @@
#include <QTextStream>
#include <QStandardPaths>
// boost includes
#include <boost/bind.hpp>
//**********************************************************************************
// Local namespace stuff
//**********************************************************************************
@ -1130,7 +1127,7 @@ int Preferences::levelFormatsCount() const {
int Preferences::matchLevelFormat(const TFilePath &fp) const {
LevelFormatVector::const_iterator lft =
std::find_if(m_levelFormats.begin(), m_levelFormats.end(),
boost::bind(&LevelFormat::matches, _1, boost::cref(fp)));
[&fp](const LevelFormat &format) { return format.matches(fp); });
return (lft != m_levelFormats.end()) ? lft - m_levelFormats.begin() : -1;
}