diff --git a/toonz/sources/common/tstream/tpersistset.cpp b/toonz/sources/common/tstream/tpersistset.cpp index 34a14a0..5c731ce 100644 --- a/toonz/sources/common/tstream/tpersistset.cpp +++ b/toonz/sources/common/tstream/tpersistset.cpp @@ -3,9 +3,6 @@ // TnzCore includes #include "tstream.h" -// tcg includes -#include "tcg/tcg_function_types.h" - // STD includes #include @@ -26,16 +23,13 @@ TPersistSet::~TPersistSet() { //------------------------------------------------------------------ void TPersistSet::insert(std::unique_ptr object) { - struct locals { - inline static bool sameType(TPersist *a, TPersist *b) { - return (typeid(*a) == typeid(*b)); - } + auto const sameType = [&object](TPersist *x) { + return typeid(*object.get()) == typeid(*x); }; // Remove any object with the same type id std::vector::iterator pt = - std::remove_if(m_objects.begin(), m_objects.end(), - tcg::bind1st(&locals::sameType, object.get())); + std::remove_if(m_objects.begin(), m_objects.end(), sameType); std::for_each(pt, m_objects.end(), std::default_delete()); m_objects.erase(pt, m_objects.end()); diff --git a/toonz/sources/include/tcg/function_types.h b/toonz/sources/include/tcg/function_types.h deleted file mode 100644 index 0e07f99..0000000 --- a/toonz/sources/include/tcg/function_types.h +++ /dev/null @@ -1,183 +0,0 @@ -#pragma once - -#ifndef TCG_FUNCTION_TYPES_H -#define TCG_FUNCTION_TYPES_H - -// tcg includes -#include "traits.h" - -// STD includes -#include - -/*! - \file function_types.h - - \brief This file contains some template class types useful to convert - functions - into functors at compile-time <\I>, with minimal memory - overhead. -*/ - -namespace tcg { - -//************************************************************************************ -// Function Objects definition -//************************************************************************************ - -template -struct function; - -//--------------------------------------------------------------------------- - -template -struct function : public std::unary_function { - Ret operator()() const { return f(); } -}; - -//--------------------------------------------------------------------------- - -template -struct function : public std::unary_function { - Ret operator()(Arg arg) const { return f(arg); } -}; - -//--------------------------------------------------------------------------- - -template -struct function - : public std::binary_function { - Ret operator()(Arg1 arg1, Arg2 arg2) const { return f(arg1, arg2); } -}; - -//************************************************************************************ -// Member Function Objects definition -//************************************************************************************ - -template -struct function : public std::unary_function { - Ret operator()(C &c) const { return (c.*f)(); } -}; - -//--------------------------------------------------------------------------- - -template -struct function - : public std::unary_function { - Ret operator()(const C &c) const { return (c.*f)(); } -}; - -//--------------------------------------------------------------------------- - -template -struct function - : public std::binary_function { - Ret operator()(C &c, Arg arg) const { return (c.*f)(arg); } -}; - -//--------------------------------------------------------------------------- - -template -struct function - : public std::binary_function { - Ret operator()(const C &c, Arg arg) const { return (c.*f)(arg); } -}; - -//************************************************************************************ -// Binder functors -//************************************************************************************ - -/*! - \brief Binary function object binder generalizing \p std::binder1st with - an explicitly specifiable bound type. - - \note Unlike std::binder1st, this binder accepts functors whose arguments - are reference types. - - \sa Helper function tcg::bind1st(). - - \remark This class currently adds an additional arguments copy. - Be warned of this when using heavyweight argument types. -*/ - -template ::arg1_type> -class binder1st - : public std::unary_function< - typename function_traits::arg2_type, // Forward function types - typename function_traits::ret_type> // -{ -public: - binder1st(const Func &func, Arg arg1) : m_func(func), m_arg1(arg1) {} - - typename function_traits::ret_type operator()( - typename function_traits::arg2_type arg2) - const // NOTE: Double copy - { - return m_func(m_arg1, arg2); - } - -protected: - Func m_func; - Arg m_arg1; -}; - -//--------------------------------------------------------------------------- - -template ::arg2_type> -class binder2nd - : public std::unary_function::arg1_type, - typename function_traits::ret_type> { -public: - binder2nd(const Func &func, Arg arg2) : m_func(func), m_arg2(arg2) {} - - typename function_traits::ret_type operator()( - typename function_traits::arg1_type arg1) const { - return m_func(arg1, m_arg2); - } - -protected: - Func m_func; - Arg m_arg2; -}; - -//--------------------------------------------------------------------------- - -/*! - \brief Helper function for the creation of binder objects with automatic - type deduction. - - \warning Unlike std::bind1st, the bound argument type is the one declared - by the function object. This is typically a commodity, but - be aware of the subtle implications: - - \li Only parameters copied by value result in a copied - bound argument. - \li Avoid temporaries as bound reference arguments. - - \sa Class tcg::binder1st. -*/ - -template -inline binder1st bind1st(const Func &func, const Arg &arg1) { - return binder1st(func, arg1); -} - -template -inline binder1st bind1st(const Func &func, Arg &arg1) { - return binder1st(func, arg1); -} - -//--------------------------------------------------------------------------- - -template -inline binder2nd bind2nd(const Func &func, const Arg &arg2) { - return binder2nd(func, arg2); -} - -template -inline binder2nd bind2nd(const Func &func, Arg &arg2) { - return binder2nd(func, arg2); -} - -} // namespace tcg - -#endif // TCG_FUNCTION_TYPES_H diff --git a/toonz/sources/include/tcg/tcg_function_types.h b/toonz/sources/include/tcg/tcg_function_types.h deleted file mode 100644 index 442d91a..0000000 --- a/toonz/sources/include/tcg/tcg_function_types.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "function_types.h" diff --git a/toonz/sources/stdfx/shaderfx.cpp b/toonz/sources/stdfx/shaderfx.cpp index bccff39..a427a64 100644 --- a/toonz/sources/stdfx/shaderfx.cpp +++ b/toonz/sources/stdfx/shaderfx.cpp @@ -29,9 +29,6 @@ // Glew include #include -// tcg includes -#include "tcg/tcg_function_types.h" - // Boost includes #include #include @@ -953,12 +950,9 @@ void ShaderFx::doCompute(TTile &tile, double frame, } ~TexturesStorage() { - typedef tcg::function - UnloadFunc; - - std::for_each(m_texIds.begin(), m_texIds.end(), - tcg::bind1st(UnloadFunc(), m_ctx)); + for (auto const &texId : m_texIds) { + m_ctx.unloadTexture(texId); + } } void load(const TRasterP &ras, GLuint texUnit) { diff --git a/toonz/sources/tnzext/plasticskeleton.cpp b/toonz/sources/tnzext/plasticskeleton.cpp index 198b95f..721f49f 100644 --- a/toonz/sources/tnzext/plasticskeleton.cpp +++ b/toonz/sources/tnzext/plasticskeleton.cpp @@ -12,7 +12,6 @@ // tcg includes #include "tcg/tcg_misc.h" #include "tcg/tcg_pool.h" -#include "tcg/tcg_function_types.h" #include "ext/plasticskeleton.h" diff --git a/toonz/sources/tnzext/plasticskeletondeformation.cpp b/toonz/sources/tnzext/plasticskeletondeformation.cpp index fa49995..679e466 100644 --- a/toonz/sources/tnzext/plasticskeletondeformation.cpp +++ b/toonz/sources/tnzext/plasticskeletondeformation.cpp @@ -13,7 +13,6 @@ // tcg includes #include "tcg/tcg_misc.h" -#include "tcg/tcg_function_types.h" // STL includes #include @@ -645,24 +644,14 @@ int PlasticSkeletonDeformation::skeletonsCount() const { //------------------------------------------------------------------ -namespace { -namespace skeletonIds { -typedef boost::bimap::left_map::const_iterator iter_type; -typedef iter_type::value_type value_type; - -inline int func_(const value_type &val) { return val.first; } -} -} // namespace ::skeletonIds - void PlasticSkeletonDeformation::skeletonIds(skelId_iterator &begin, skelId_iterator &end) const { - using namespace ::skeletonIds; - - typedef tcg::function func; - typedef boost::transform_iterator adapt_it; + auto const f = [](const SkeletonSet::left_map::value_type &val) { + return val.first; + }; - begin = adapt_it(m_imp->m_skeletons.left.begin()); - end = adapt_it(m_imp->m_skeletons.left.end()); + begin = boost::make_transform_iterator(m_imp->m_skeletons.left.begin(), f); + end = boost::make_transform_iterator(m_imp->m_skeletons.left.end(), f); } //------------------------------------------------------------------ @@ -744,54 +733,34 @@ SkVD *PlasticSkeletonDeformation::vertexDeformation(int skelId, int v) const { //------------------------------------------------------------------ -namespace { -namespace vertexDeformations { -inline std::pair func_(const VDKey &vdKey) { - return std::make_pair(&vdKey.m_name, &vdKey.m_vd); -} -} -} // namespace ::vertexDeformations - void PlasticSkeletonDeformation::vertexDeformations(vd_iterator &begin, vd_iterator &end) const { - using namespace ::vertexDeformations; + auto const f = [](const VDKey &vdKey) { + return std::make_pair(&vdKey.m_name, &vdKey.m_vd); + }; - typedef std::pair (*func_type)(const VDKey &vdKey); - typedef tcg::function func; - typedef boost::transform_iterator adapt_it; - - begin = adapt_it(m_imp->m_vds.begin()); - end = adapt_it(m_imp->m_vds.end()); + begin = boost::make_transform_iterator(m_imp->m_vds.begin(), f); + end = boost::make_transform_iterator(m_imp->m_vds.end(), f); } //------------------------------------------------------------------ -namespace { -namespace vdSkeletonVertices { -inline std::pair func_(const std::map::value_type &val) { - return std::make_pair(val.first, val.second); -} -} -} // namespace ::vdSkeletonVertices - void PlasticSkeletonDeformation::vdSkeletonVertices(const QString &vertexName, vx_iterator &begin, vx_iterator &end) const { - using namespace ::vdSkeletonVertices; - - typedef std::pair (*func_type)( - const std::map::value_type &); - typedef tcg::function func; - typedef boost::transform_iterator::const_iterator> - adapt_it; + auto const f = [](const std::map::value_type &val) { + return std::make_pair(val.first, val.second); + }; SkVDSet::const_iterator nt(m_imp->m_vds.find(vertexName)); - if (nt == m_imp->m_vds.end()) - begin = adapt_it(), end = adapt_it(); - else - begin = adapt_it(nt->m_vIndices.begin()), - end = adapt_it(nt->m_vIndices.end()); + if (nt == m_imp->m_vds.end()) { + begin = vx_iterator(); + end = vx_iterator(); + } else { + begin = boost::make_transform_iterator(nt->m_vIndices.begin(), f); + end = boost::make_transform_iterator(nt->m_vIndices.end(), f); + } } //------------------------------------------------------------------ diff --git a/toonz/sources/tnztools/plastictool.cpp b/toonz/sources/tnztools/plastictool.cpp index 364bb17..ddd3196 100644 --- a/toonz/sources/tnztools/plastictool.cpp +++ b/toonz/sources/tnztools/plastictool.cpp @@ -45,7 +45,6 @@ #include "tcg/tcg_macros.h" #include "tcg/tcg_point_ops.h" #include "tcg/tcg_list.h" -#include "tcg/tcg_function_types.h" #include "tcg/tcg_iterator_ops.h" //**************************************************************************************** @@ -761,11 +760,9 @@ PlasticSkeletonP PlasticTool::skeleton() const { //------------------------------------------------------------------------ PlasticSkeleton &PlasticTool::deformedSkeleton() { - typedef tcg::function - Func; - - return m_deformedSkeleton(tcg::bind1st(Func(), *this)); + return m_deformedSkeleton([this](PlasticSkeleton &deformedSkeleton) { + updateDeformedSkeleton(deformedSkeleton); + }); } //------------------------------------------------------------------------ diff --git a/toonz/sources/tnztools/plastictool_build.cpp b/toonz/sources/tnztools/plastictool_build.cpp index a4a2094..b2b4bda 100644 --- a/toonz/sources/tnztools/plastictool_build.cpp +++ b/toonz/sources/tnztools/plastictool_build.cpp @@ -14,7 +14,6 @@ // tcg includes #include "tcg/tcg_point_ops.h" -#include "tcg/tcg_function_types.h" #include "plastictool.h" diff --git a/toonz/sources/tnztools/plastictool_meshedit.cpp b/toonz/sources/tnztools/plastictool_meshedit.cpp index d4da3c4..d2bf23c 100644 --- a/toonz/sources/tnztools/plastictool_meshedit.cpp +++ b/toonz/sources/tnztools/plastictool_meshedit.cpp @@ -11,7 +11,6 @@ // tcg includes #include "tcg/tcg_macros.h" #include "tcg/tcg_point_ops.h" -#include "tcg/tcg_function_types.h" // boost includes #include @@ -257,8 +256,9 @@ bool buildEdgeCuts(const TMeshImage &mi, static int testSingleMesh(const edges_container &edges) { assert(!edges.empty()); return (std::find_if(edges.begin(), edges.end(), - tcg::bind2nd(&differentMesh, edges.front())) == - edges.end()) + [&edges](const MeshIndex &x) { + return differentMesh(x, edges.front()); + }) == edges.end()) ? edges.front().m_meshIdx : -1; } @@ -318,7 +318,8 @@ bool buildEdgeCuts(const TMeshImage &mi, // one) int *ept, *epEnd = endPoints + 2; - ept = std::find_if(endPoints, epEnd, tcg::bind1st(&borderVertex, mesh)); + ept = std::find_if(endPoints, epEnd, + [&mesh](int v) { return borderVertex(mesh, v); }); if (ept == epEnd) { // There is no boundary endpoint if (edges.size() < 2) // We should not cut the mesh on a @@ -568,8 +569,9 @@ void splitMesh(TMeshImage &mi, int meshIdx, int lastBoundaryVertex) { { const vertex_type &lbVx = mesh.vertex(lastBoundaryVertex); - vertex_type::edges_const_iterator et = std::find_if( - lbVx.edgesBegin(), lbVx.edgesEnd(), tcg::bind1st(&borderEdge, mesh)); + vertex_type::edges_const_iterator et = + std::find_if(lbVx.edgesBegin(), lbVx.edgesEnd(), + [&mesh](int e) { return borderEdge(mesh, e); }); assert(et != lbVx.edgesEnd()); e = *et; @@ -619,7 +621,9 @@ bool cutMesh(TMeshImage &mi, const PlasticTool::MeshSelection &edgesSelection) { } // Cut edges, in the order specified by edgeCuts - std::for_each(ecBegin, edgeCuts.end(), tcg::bind1st(&cutEdge, mesh)); + std::for_each(ecBegin, edgeCuts.end(), [&mesh](const EdgeCut &edgeCut) { + return cutEdge(mesh, edgeCut); + }); // Finally, the mesh could have been split in 2 - we need to separate // the pieces if needed diff --git a/toonz/sources/toonz/adjustthicknesspopup.cpp b/toonz/sources/toonz/adjustthicknesspopup.cpp index 75af9cb..7296c5d 100644 --- a/toonz/sources/toonz/adjustthicknesspopup.cpp +++ b/toonz/sources/toonz/adjustthicknesspopup.cpp @@ -47,7 +47,6 @@ // tcg includes #include "tcg/tcg_numeric_ops.h" -#include "tcg/tcg_function_types.h" // boost includes #include @@ -1013,31 +1012,28 @@ AdjustThicknessUndo::AdjustThicknessUndo(const SelectionData &selData, //-------------------------------------------------------------- void AdjustThicknessUndo::redo() const { - struct locals { - static void processFrame(const AdjustThicknessUndo &undo, int frameIdx) { - TXshSimpleLevel *sl = undo.m_selData.m_sl.getPointer(); - assert(sl); - - const TFrameId &fid = sl->index2fid(frameIdx); + auto const processFrame = [this](int frameIdx) { + TXshSimpleLevel *sl = m_selData.m_sl.getPointer(); + assert(sl); - // Backup input frame - TVectorImageP viIn = sl->getFullsampledFrame(fid, false); - if (!viIn) return; + const TFrameId &fid = sl->index2fid(frameIdx); - undo.m_originalImages.push_back(ImageBackup(fid, viIn)); + // Backup input frame + TVectorImageP viIn = sl->getFullsampledFrame(fid, false); + if (!viIn) return; - // Process required frame - TVectorImageP viOut = ::processFrame( - undo.m_selData, frameIdx, undo.m_fromTransform, undo.m_toTransform); + m_originalImages.push_back(ImageBackup(fid, viIn)); - sl->setFrame(fid, viOut); + // Process required frame + TVectorImageP viOut = ::processFrame( + m_selData, frameIdx, m_fromTransform, m_toTransform); - // Ensure the level data is invalidated suitably - sl->setDirtyFlag(true); - IconGenerator::instance()->invalidate(sl, fid); - } + sl->setFrame(fid, viOut); - }; // locals + // Ensure the level data is invalidated suitably + sl->setDirtyFlag(true); + IconGenerator::instance()->invalidate(sl, fid); + }; m_originalImages.clear(); @@ -1047,11 +1043,11 @@ void AdjustThicknessUndo::redo() const { std::for_each( boost::make_counting_iterator(0), boost::make_counting_iterator(m_selData.m_sl->getFrameCount()), - tcg::bind1st(&locals::processFrame, *this)); + processFrame); break; case SelectionData::SELECTED_FRAMES: std::for_each(m_selData.m_frameIdxs.begin(), m_selData.m_frameIdxs.end(), - tcg::bind1st(&locals::processFrame, *this)); + processFrame); break; } } diff --git a/toonz/sources/toonz/columncommand.cpp b/toonz/sources/toonz/columncommand.cpp index cf77797..6195b92 100644 --- a/toonz/sources/toonz/columncommand.cpp +++ b/toonz/sources/toonz/columncommand.cpp @@ -52,9 +52,6 @@ #include #include -// tcg includes -#include "tcg/tcg_function_types.h" - #include //************************************************************************* @@ -63,11 +60,6 @@ namespace { -bool filterNegatives(int c) { return (c < 0); } -typedef tcg::function filterNegatives_fun; - -//----------------------------------------------------------------------------- - bool canRemoveFx(const std::set &leaves, TFx *fx) { bool removeFx = false; for (int i = 0; i < fx->getInputPortCount(); i++) { diff --git a/toonz/sources/toonz/loadfoldercommand.cpp b/toonz/sources/toonz/loadfoldercommand.cpp index 7fdec12..7347268 100644 --- a/toonz/sources/toonz/loadfoldercommand.cpp +++ b/toonz/sources/toonz/loadfoldercommand.cpp @@ -30,9 +30,6 @@ #include #include -// tcg includes -#include "tcg/tcg_function_types.h" - // boost includes #include #include @@ -209,20 +206,16 @@ static const FormatData l_formatDatas[] = { typedef std::pair RsrcKey; typedef std::map RsrcMap; -bool differentPath(const RsrcMap::value_type &a, const RsrcMap::value_type &b) { +auto const differentPath = [](const RsrcMap::value_type &a, + const RsrcMap::value_type &b) -> bool { return (a.first.first < b.first.first) || (b.first.first < a.first.first); -} +}; struct buildResources_locals { static bool isValid(const RsrcMap::value_type &rsrcVal) { return (isLoadable(rsrcVal.first.first.m_relFp) && !rsrcVal.second.empty()); } - typedef tcg::function - DifferentPath; - static Resource toResource(const RsrcMap::value_type &rsrcVal) { return Resource(rsrcVal.first.first, rsrcVal.second); } @@ -334,12 +327,11 @@ void buildResources(std::vector &resources, const TFilePath &rootPath, for (rt = rsrcMap.begin(); rt != rEnd; ++rt) locals::mergeInto(rt, rsrcMap); // Export valid data into the output resources collection - boost::copy( - rsrcMap | boost::adaptors::filtered(locals::isValid) | - boost::adaptors::adjacent_filtered( - locals::DifferentPath()) // E.g. A.xxxx.tga and Axxxx.tga - | boost::adaptors::transformed(locals::toResource), - std::back_inserter(resources)); + boost::copy(rsrcMap | boost::adaptors::filtered(locals::isValid) | + boost::adaptors::adjacent_filtered( + differentPath) // E.g. A.xxxx.tga and Axxxx.tga + | boost::adaptors::transformed(locals::toResource), + std::back_inserter(resources)); } // Look for level options associated to each level diff --git a/toonz/sources/toonzlib/fxcommand.cpp b/toonz/sources/toonzlib/fxcommand.cpp index e2a7bf5..3a250d8 100644 --- a/toonz/sources/toonzlib/fxcommand.cpp +++ b/toonz/sources/toonzlib/fxcommand.cpp @@ -35,7 +35,6 @@ // tcg includes #include "tcg/tcg_macros.h" #include "tcg/tcg_base.h" -#include "tcg/tcg_function_types.h" #include @@ -742,9 +741,6 @@ namespace { bool containsInputFx(const QList &fxs, const TFxCommand::Link &link) { return fxs.contains(link.m_inputFx); } -typedef tcg::function &, const TFxCommand::Link &), - containsInputFx> - ContainsInputFx_fun; } // namespace @@ -797,7 +793,9 @@ void InsertFxUndo::initialize(const TFxP &newFx, int row, int col) { m_selectedLinks.end()); m_selectedLinks.erase( std::remove_if(m_selectedLinks.begin(), m_selectedLinks.end(), - tcg::bind1st(::ContainsInputFx_fun(), m_selectedFxs)), + [this](const TFxCommand::Link &link) { + return containsInputFx(m_selectedFxs, link); + }), m_selectedLinks.end()); // Build an fx for each of the specified inputs @@ -1864,7 +1862,9 @@ void DeleteLinksUndo::initialize() { // Remove invalid links m_links.erase(std::remove_if(m_links.begin(), m_links.end(), - tcg::bind1st(&locals::isInvalid, fxDag)), + [fxDag](const TFxCommand::Link &link) { + return locals::isInvalid(fxDag, link); + }), m_links.end()); std::list::iterator lt, lEnd(m_links.end()); @@ -2502,14 +2502,6 @@ void UndoPasteFxs::initialize(const std::map &zeraryFxColumnSize, fx->renamePort(qPortName.toStdString(), qNewPortName.toStdString()); } } - - static bool circularSubxsheet(TXsheet *xsh, const TXshColumnP &col) { - return xsh->checkCircularReferences(col.getPointer()); - } - - static void push_back(std::vector &fxs, TFx *fx) { - fxs.push_back(fx); - } }; TXsheet *xsh = m_xshHandle->getXsheet(); @@ -2590,9 +2582,12 @@ void UndoPasteFxs::initialize(const std::map &zeraryFxColumnSize, } // Filter columns - m_columns.erase(std::remove_if(m_columns.begin(), m_columns.end(), - tcg::bind1st(&locals::circularSubxsheet, xsh)), - m_columns.end()); + auto const circularSubxsheet = [xsh](const TXshColumnP &col) -> bool { + return xsh->checkCircularReferences(col.getPointer()); + }; + m_columns.erase( + std::remove_if(m_columns.begin(), m_columns.end(), circularSubxsheet), + m_columns.end()); // Initialize columns std::list::const_iterator ct, cEnd(m_columns.end()); @@ -2608,7 +2603,7 @@ void UndoPasteFxs::initialize(const std::map &zeraryFxColumnSize, std::vector fxs; fxs.reserve(m_fxs.size() + m_columns.size()); - for_each_fx(tcg::bind1st(&locals::push_back, fxs)); + for_each_fx([&fxs](TFx *fx) { fxs.push_back(fx); }); // We need to store input links for these fxs size_t f, fCount = fxs.size(); @@ -2798,9 +2793,9 @@ void UndoAddPasteFxs::initialize(TFx *inFx) { m_linkIn = TFxCommand::Link(inFx, ifx, 0); // Furthermore, clone the group stack from inFx into each inserted fx - typedef tcg::function - clone_fun; - for_each_fx(tcg::bind1st(clone_fun(), inFx)); + auto const clone_fun = static_cast(FxCommandUndo::cloneGroupStack); + for_each_fx( + [inFx, clone_fun](TFx *toFx) { clone_fun(inFx, toFx); }); } //------------------------------------------------------ @@ -2813,11 +2808,10 @@ void UndoAddPasteFxs::redo() const { FxCommandUndo::attach(xsh, m_linkIn, false); // Copiare l'indice di gruppo dell'fx di input - typedef tcg::function - copy_fun; - for_each_fx( - tcg::binder1st(copy_fun(), m_linkIn.m_inputFx.getPointer())); + auto const copy_fun = static_cast(FxCommandUndo::copyGroupEditLevel); + for_each_fx([this, copy_fun](TFx *toFx) { + copy_fun(m_linkIn.m_inputFx.getPointer(), toFx); + }); } UndoPasteFxs::redo(); @@ -3182,8 +3176,12 @@ void UndoDisconnectFxs::undo() const { FxDag *fxDag = xsh->getFxDag(); // Restore the old links - tcg::binder1st attacher(&UndoDisconnectFxs::attach, xsh); - tcg::binder1st xshDetacher(&UndoDisconnectFxs::detachXsh, xsh); + auto const attacher = [xsh](const TFxCommand::Link &link) { + return UndoDisconnectFxs::attach(xsh, link); + }; + auto const xshDetacher = [xsh](const TFxCommand::Link &link) { + return UndoDisconnectFxs::detachXsh(xsh, link); + }; std::for_each(m_undoLinksIn.begin(), m_undoLinksIn.end(), attacher); std::for_each(m_undoLinksOut.begin(), m_undoLinksOut.end(), attacher); @@ -3328,8 +3326,9 @@ void UndoConnectFxs::undo() const { FxCommandUndo::attach(xsh, m_link, false); // Restore the old fxs' group data - tcg::function restore_fun; - std::for_each(m_undoGroupDatas.begin(), m_undoGroupDatas.end(), restore_fun); + for (auto const &groupData : m_undoGroupDatas) { + groupData.restore(); + } UndoDisconnectFxs::undo(); } diff --git a/toonz/sources/toonzlib/fxdag.cpp b/toonz/sources/toonzlib/fxdag.cpp index 5ca96f7..968865d 100644 --- a/toonz/sources/toonzlib/fxdag.cpp +++ b/toonz/sources/toonzlib/fxdag.cpp @@ -14,9 +14,6 @@ // TnzCore includes #include "tstream.h" -// tcg includes -#include "tcg/function_types.h" - // STD includes //#include diff --git a/toonz/sources/toonzlib/toutlinevectorizer.cpp b/toonz/sources/toonzlib/toutlinevectorizer.cpp index 876f488..c8196b0 100644 --- a/toonz/sources/toonzlib/toutlinevectorizer.cpp +++ b/toonz/sources/toonzlib/toutlinevectorizer.cpp @@ -15,7 +15,6 @@ // tcg includes #include "tcg/tcg_numeric_ops.h" -#include "tcg/tcg_function_types.h" // STD includes #include @@ -1272,9 +1271,7 @@ void VectorizerCore::applyFillColors(TRegion *r, const TRasterP &ras, TPalette *palette, const CenterlineConfiguration &c, int regionCount) { - struct locals { - static inline bool alwaysTrue(const TPixelCM32 &) { return true; } - }; + auto const alwaysTrue = [](const TPixelCM32 &) { return true; }; TRasterCM32P rt = ras; TRaster32P rr = ras; @@ -1306,29 +1303,40 @@ void VectorizerCore::applyFillColors(TRegion *r, const TRasterP &ras, bool tookPoint = isBrightRegion - ? rt - ? getInternalPoint( - rt, tcg::bind2nd(cm_func(isBright), c.m_threshold), - inverse, c, r, - pd) || // If no bright pixel could be found, - getInternalPoint(rt, locals::alwaysTrue, inverse, c, r, - pd) - : // then any pixel inside the region + ? rt ? getInternalPoint( + rt, + std::bind(cm_func(isBright), std::placeholders::_1, + c.m_threshold), + inverse, c, r, pd) || + // If no bright pixel could be found, + getInternalPoint(rt, alwaysTrue, inverse, c, r, + pd) + : // then any pixel inside the region rr ? getInternalPoint( - rr, tcg::bind2nd(rgbm_func(isBright), c.m_threshold), + rr, + std::bind(rgbm_func(isBright), std::placeholders::_1, + c.m_threshold), inverse, c, r, pd) : // must suffice. getInternalPoint( - rgr, tcg::bind2nd(gr_func(isBright), c.m_threshold), + rgr, + std::bind(gr_func(isBright), std::placeholders::_1, + c.m_threshold), inverse, c, r, pd) - : rt ? getInternalPoint(rt, - tcg::bind2nd(cm_func(isDark), c.m_threshold), - inverse, c, r, pd) + : rt ? getInternalPoint( + rt, + std::bind(cm_func(isDark), std::placeholders::_1, + c.m_threshold), + inverse, c, r, pd) : rr ? getInternalPoint( - rr, tcg::bind2nd(rgbm_func(isDark), c.m_threshold), + rr, + std::bind(rgbm_func(isDark), std::placeholders::_1, + c.m_threshold), inverse, c, r, pd) : getInternalPoint( - rgr, tcg::bind2nd(gr_func(isDark), c.m_threshold), + rgr, + std::bind(gr_func(isDark), std::placeholders::_1, + c.m_threshold), inverse, c, r, pd); if (tookPoint) { diff --git a/toonz/sources/toonzlib/tstageobject.cpp b/toonz/sources/toonzlib/tstageobject.cpp index 5ff449d..250e193 100644 --- a/toonz/sources/toonzlib/tstageobject.cpp +++ b/toonz/sources/toonzlib/tstageobject.cpp @@ -29,9 +29,6 @@ // Qt includes #include -// tcg includes -#include "tcg/tcg_function_types.h" - // STD includes #include #include @@ -481,10 +478,7 @@ TStageObject::~TStageObject() { //----------------------------------------------------------------------------- const TStageObject::LazyData &TStageObject::lazyData() const { - typedef tcg::function - Func; - return m_lazyData(tcg::bind1st(Func(), *this)); + return m_lazyData([this](LazyData &ld) { this->update(ld); }); } //-----------------------------------------------------------------------------