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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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