New user self-registration is currently disabled. Please email eigen-core-team @ if you need an account.
Bug 872 - std::binder2nd deprecated warnings with C++11
std::binder2nd deprecated warnings with C++11
Product: Eigen
Classification: Unclassified
Component: General
3.3 (current stable)
All All
: Normal Compilation Problem
Assigned To: Nobody
Depends on:
Blocks: 97 3.3
  Show dependency treegraph
Reported: 2014-09-03 22:27 UTC by Johannis Bauer
Modified: 2015-06-29 18:13 UTC (History)
6 users (show)

Replacing binder1st/binder2nd usage by custom functors (10.10 KB, patch)
2015-05-04 12:53 UTC, Christoph Hertzberg
no flags Details | Diff

Description Johannis Bauer 2014-09-03 22:27:27 UTC
When compiling with C++11 support on the Intel compilers, lots of verbose warnings are emitted that std::binder2nd is deprecated.
Comment 1 Christoph Hertzberg 2015-04-16 12:57:29 UTC
These also arise when compiling with clang.
Eventually, we'll need to replace these by custom functors anyways if we want to use vectorized comparisons (Bug 97)
Comment 2 Christoph Hertzberg 2015-05-04 12:53:46 UTC
Created attachment 572 [details]
Replacing binder1st/binder2nd usage by custom functors

In the attached patch I replaced all usages of binder1st/binder2nd by custom functors which are then called with Array::Constant(...) as second object.
Furthermore, operator< and operator> have the same return type (with swapped arguments now (the same for <=, >=).
Probably the names can be chosen differently and some boiler-plate code can be hidden inside macros.
The functors also don't provide packet-functionality, yet (Bug 97).
Comment 3 Gael Guennebaud 2015-05-05 16:33:37 UTC
Thank you for the patch, the introduction of an enum ComparisonName seems to be a bit overkill, and perhaps it would have been simpler to keep the std::* functors for now as the real fix here consists in using Constant instead of bind (as this is already the case for min/max and perhaps others) but this is preparing bug 97, so ok.
Comment 4 Christoph Hertzberg 2015-05-07 15:32:05 UTC
Pushed here (after hiding boiler plate code into macros):

The whole ComparisonName stuff is indeed not necessary for this, but as mentioned, this prepares resolving Bug 97.
Comment 5 Chris Dyer 2015-05-07 20:03:28 UTC
Just happened to see this push. Unfortunately, it doesn't fix all the deprecation warnings with C++11 and g++-5.1.0:

/home/chris/neweig/eigen/Eigen/src/SparseCore/../plugins/MatrixCwiseUnaryOps.h:17:27: warning: ‘template<class _Operation> class std::binder1st’ is deprecated [-Wdeprecated-declarations]
 typedef CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >, const Derived> CwiseScalarEqualReturnType;
Comment 6 Christoph Hertzberg 2015-05-07 20:08:45 UTC
Hm, right. Probably this requires unary functors after all.
Comment 8 Jason Rhinelander 2015-06-29 18:13:02 UTC
I'm still getting these warnings in 3.2.5, but not on the devel branch.  The 3.2 branch apparently also needs this change backported:

to avoid:

/home/jagerman/research/fracdist/eigen3/Eigen/src/Core/Functors.h:973:28: warning: ‘template<class _Operation> class std::binder2nd’ is deprecated [-Wdeprecated-declarations]
 struct functor_traits<std::binder2nd<T> >

Note You need to log in before you can comment on or make changes to this bug.