Skip to content

Commit

Permalink
Merge pull request #1287 from phcerdan/replace_binder2n_from_master
Browse files Browse the repository at this point in the history
Replace deprecated binder2nd and binder1st
  • Loading branch information
dcoeurjo authored Nov 7, 2017
2 parents 46f43e0 + 2053aff commit a81712e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions examples/graph/volDistanceTraversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ int main( int argc, char** argv )
typedef SCellEmbedder::Value RealPoint;
typedef RealPoint::Coordinate Scalar;
typedef ExactPredicateLpSeparableMetric<Space,2> Distance;

typedef std::binder1st< Distance > DistanceToPoint;
using DistanceToPoint = std::function<double(const Space::Point &)>;
typedef DGtal::functors::Composer<SCellEmbedder, DistanceToPoint, Scalar> VertexFunctor;
typedef DistanceBreadthFirstVisitor< MyDigitalSurface, VertexFunctor, std::set<SCell> >
MyDistanceVisitor;
Expand All @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions src/DGtal/graph/DistanceBreadthFirstVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ namespace DGtal
typedef VertexEmbedder::Value RealPoint;
typedef RealPoint::Coordinate Scalar;
typedef ExactPredicateLpSeparableMetric<Space,2> Distance; // Euclidean distance
typedef std::binder1st< Distance > EDToPoint; // Fix one point
using EDToPoint = std::function<double(const Space::Point &)>; // Fix one point
typedef Composer<VertexEmbedder, EDToPoint, Scalar> 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() )
Expand Down
1 change: 0 additions & 1 deletion src/DGtal/io/colormaps/TickedColorMap.ih
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

//////////////////////////////////////////////////////////////////////////////
#include <cstdlib>
#include <boost/bind.hpp>
//////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 0 additions & 1 deletion src/DGtal/shapes/Mesh.ih
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
//////////////////////////////////////////////////////////////////////////////
#include <limits>
#include <cstdlib>
#include <boost/bind.hpp>
#include <DGtal/kernel/BasicPointPredicates.h>
//////////////////////////////////////////////////////////////////////////////

Expand Down
8 changes: 6 additions & 2 deletions tests/base/testBasicFunctors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ bool testBasicFunctors()
//binary to unary functor
{
int i = -5;
std::binder2nd<std::minus<int> > b(std::minus<int>(), 0);
// With function and bind:
std::function<int(int)> b = std::bind(std::minus<int>(), std::placeholders::_1, 0);
//i - 0
nbok += ( b(i) == -5 ) ? 1 : 0;
nb++;
std::binder2nd<std::plus<int> > b2(std::plus<int>(), 2);
// With a lambda:
auto b2 = [](int v) -> int {
return v + 2;
};
//i + 2
nbok += ( b2(i) == -3 ) ? 1 : 0;
nb++;
Expand Down
5 changes: 3 additions & 2 deletions tests/graph/testDistancePropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool testDistancePropagation()
typedef VertexEmbedder::Value RealPoint;
typedef RealPoint::Coordinate Scalar;
typedef ExactPredicateLpSeparableMetric<Space,2> Distance;
typedef std::binder1st< Distance > DistanceToPoint;
using DistanceToPoint = std::function<double(const Space::Point &)>;
typedef DGtal::functors::Composer<VertexEmbedder, DistanceToPoint, Scalar> VertexFunctor;
typedef DistanceBreadthFirstVisitor< Object, VertexFunctor, std::set<Point> > Visitor;

Expand All @@ -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 );

Expand Down
8 changes: 5 additions & 3 deletions tests/kernel/testImagesSetsUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,11 @@ bool testSetFromImage()
DigitalSet aSet5(d);
DigitalSetInserter<DigitalSet> inserter5(aSet5);
//predicate construction
typedef std::equal_to<Image::Value> EqualBinaryFunctor;
typedef std::binder2nd<EqualBinaryFunctor> ValuePredicate;
ValuePredicate equalTo1 (EqualBinaryFunctor(),1);
using ValuePredicate = std::function<bool(const Image::Value &)>;
ValuePredicate equalTo1 = [](const Image::Value & v)
{
return v == 1;
};
functors::PointFunctorPredicate<Image, ValuePredicate> pred(image, equalTo1);
//all points whose value is 1
setFromPointsRangeAndPredicate( d.begin(), d.end(), inserter5, pred );
Expand Down
4 changes: 2 additions & 2 deletions tests/kernel/testPointPredicateConcepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ int main( int argc, char** argv )

bool res = true;
typedef ImageSelector<Z3i::Domain, int>::Type IntImage;
typedef std::binder2nd< std::less<int> > IntPredicate;
using IntPredicate = std::function<bool(int)>;
typedef ImageSelector<Z3i::Domain, float>::Type FloatImage;
typedef std::binder2nd< std::greater<float> > FloatPredicate;
using FloatPredicate = std::function<bool(float)>;
res &= testPointPredicateConcepts<IntImage, IntPredicate, FloatImage, FloatPredicate>();

trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
Expand Down

0 comments on commit a81712e

Please sign in to comment.