diff --git a/ChangeLog.md b/ChangeLog.md index 9e8d4a9074..b65ca22332 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -68,6 +68,8 @@ [#1226](https://github.com/DGtal-team/DGtal/pull/1226)) - New mandatory dependency for DGtal: zlib must be installed in the system. (David Coeurjolly, [#1228](https://github.com/DGtal-team/DGtal/pull/1228)) + - Remove cpp11 deprecated usage of std::binder1st and std::binder2nd --generates error with c++17 flag. + (Pablo Hernandez, [#1287](https://github.com/DGtal-team/DGtal/pull/1287)) - *Topology Package* - Implementation of ParDirCollapse with CollapseSurface and CollapseIsthmus. diff --git a/examples/graph/volDistanceTraversal.cpp b/examples/graph/volDistanceTraversal.cpp index f53957ded6..10cdc8b817 100644 --- a/examples/graph/volDistanceTraversal.cpp +++ b/examples/graph/volDistanceTraversal.cpp @@ -129,8 +129,7 @@ int main( int argc, char** argv ) typedef SCellEmbedder::Value RealPoint; typedef RealPoint::Coordinate Scalar; typedef ExactPredicateLpSeparableMetric Distance; - - typedef std::binder1st< Distance > DistanceToPoint; + using DistanceToPoint = std::function; typedef DGtal::functors::Composer VertexFunctor; typedef DistanceBreadthFirstVisitor< MyDigitalSurface, VertexFunctor, std::set > MyDistanceVisitor; @@ -139,7 +138,7 @@ int main( int argc, char** argv ) SCellEmbedder embedder( ks ); Distance distance; - DistanceToPoint distanceToPoint = std::bind1st( distance, embedder( bel ) ); + DistanceToPoint distanceToPoint = std::bind( distance, embedder( bel ), std::placeholders::_1 ); VertexFunctor vfunctor( embedder, distanceToPoint ); MyDistanceVisitor visitor( digSurf, vfunctor, bel ); diff --git a/src/DGtal/graph/DistanceBreadthFirstVisitor.h b/src/DGtal/graph/DistanceBreadthFirstVisitor.h index 5fc67dcc6e..0ce4174488 100644 --- a/src/DGtal/graph/DistanceBreadthFirstVisitor.h +++ b/src/DGtal/graph/DistanceBreadthFirstVisitor.h @@ -100,14 +100,14 @@ namespace DGtal typedef VertexEmbedder::Value RealPoint; typedef RealPoint::Coordinate Scalar; typedef ExactPredicateLpSeparableMetric Distance; // Euclidean distance - typedef std::binder1st< Distance > EDToPoint; // Fix one point + using EDToPoint = std::function; // Fix one point typedef Composer VertexFunctor; // Compose the vertex embedding with the distance computation. typedef DistanceBreadthFirstVisitor< Graph, VertexFunctor > Visitor; VertexEmbedder embedder( g.space() ); //We assume the graph to be a DigitalSurface ED distance; - EDToPoint distanceToPoint = std::bind1st( distance, embedder( p ) ); + EDToPoint distanceToPoint = std::bind( distance, embedder( p ), std::placeholders::_1 ); VertexFunctor vfunctor( embedder, distanceToPoint ); DistanceBreadthFirstVisitor< Graph, VertexFunctor > visitor( g, vfunctor, p ); while ( ! visitor.finished() ) diff --git a/src/DGtal/io/colormaps/TickedColorMap.ih b/src/DGtal/io/colormaps/TickedColorMap.ih index 2c1c731fd1..32a41f62a0 100644 --- a/src/DGtal/io/colormaps/TickedColorMap.ih +++ b/src/DGtal/io/colormaps/TickedColorMap.ih @@ -29,7 +29,6 @@ ////////////////////////////////////////////////////////////////////////////// #include -#include ////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/src/DGtal/shapes/Mesh.ih b/src/DGtal/shapes/Mesh.ih index 497e1b2089..7be0db3abd 100644 --- a/src/DGtal/shapes/Mesh.ih +++ b/src/DGtal/shapes/Mesh.ih @@ -30,7 +30,6 @@ ////////////////////////////////////////////////////////////////////////////// #include #include -#include #include ////////////////////////////////////////////////////////////////////////////// diff --git a/tests/base/testBasicFunctors.cpp b/tests/base/testBasicFunctors.cpp index 475b6bd5af..560af42d43 100644 --- a/tests/base/testBasicFunctors.cpp +++ b/tests/base/testBasicFunctors.cpp @@ -114,11 +114,15 @@ bool testBasicFunctors() //binary to unary functor { int i = -5; - std::binder2nd > b(std::minus(), 0); + // With function and bind: + std::function b = std::bind(std::minus(), std::placeholders::_1, 0); //i - 0 nbok += ( b(i) == -5 ) ? 1 : 0; nb++; - std::binder2nd > b2(std::plus(), 2); + // With a lambda: + auto b2 = [](int v) -> int { + return v + 2; + }; //i + 2 nbok += ( b2(i) == -3 ) ? 1 : 0; nb++; diff --git a/tests/graph/testDistancePropagation.cpp b/tests/graph/testDistancePropagation.cpp index c2d5028e33..d1bf9f2456 100644 --- a/tests/graph/testDistancePropagation.cpp +++ b/tests/graph/testDistancePropagation.cpp @@ -101,7 +101,7 @@ bool testDistancePropagation() typedef VertexEmbedder::Value RealPoint; typedef RealPoint::Coordinate Scalar; typedef ExactPredicateLpSeparableMetric Distance; - typedef std::binder1st< Distance > DistanceToPoint; + using DistanceToPoint = std::function; typedef DGtal::functors::Composer VertexFunctor; typedef DistanceBreadthFirstVisitor< Object, VertexFunctor, std::set > Visitor; @@ -110,7 +110,8 @@ bool testDistancePropagation() VertexEmbedder embedder; Distance distance; - DistanceToPoint distanceToPoint = std::bind1st( distance, embedder( c1 ) ); + DistanceToPoint distanceToPoint = std::bind(distance, embedder(c1), std::placeholders::_1); + VertexFunctor vfunctor( embedder, distanceToPoint ); Visitor visitor( obj, vfunctor, c1 ); diff --git a/tests/kernel/testImagesSetsUtilities.cpp b/tests/kernel/testImagesSetsUtilities.cpp index 71c5d2eb2b..85db456960 100644 --- a/tests/kernel/testImagesSetsUtilities.cpp +++ b/tests/kernel/testImagesSetsUtilities.cpp @@ -203,9 +203,11 @@ bool testSetFromImage() DigitalSet aSet5(d); DigitalSetInserter inserter5(aSet5); //predicate construction - typedef std::equal_to EqualBinaryFunctor; - typedef std::binder2nd ValuePredicate; - ValuePredicate equalTo1 (EqualBinaryFunctor(),1); + using ValuePredicate = std::function; + ValuePredicate equalTo1 = [](const Image::Value & v) + { + return v == 1; + }; functors::PointFunctorPredicate pred(image, equalTo1); //all points whose value is 1 setFromPointsRangeAndPredicate( d.begin(), d.end(), inserter5, pred ); diff --git a/tests/kernel/testPointPredicateConcepts.cpp b/tests/kernel/testPointPredicateConcepts.cpp index 90a52f1495..98a7ec0239 100644 --- a/tests/kernel/testPointPredicateConcepts.cpp +++ b/tests/kernel/testPointPredicateConcepts.cpp @@ -96,9 +96,9 @@ int main( int argc, char** argv ) bool res = true; typedef ImageSelector::Type IntImage; - typedef std::binder2nd< std::less > IntPredicate; + using IntPredicate = std::function; typedef ImageSelector::Type FloatImage; - typedef std::binder2nd< std::greater > FloatPredicate; + using FloatPredicate = std::function; res &= testPointPredicateConcepts(); trace.emphase() << ( res ? "Passed." : "Error." ) << endl;