New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.Before reporting a bug, please make sure that your Eigen version is up-to-date!

Created attachment 322[details]
Proposed Patch for Eigen 3.2-beta1
C++11 supports lambda expression, which is quite useful if we combine it with Eigen. For example, Matrix::unaryExpr can handle many types of nontrivial operations without defining functional classes. Please see the example code at the end.
Current Eigen implementation does not support lambda expression
to be specified in unaryExpr if the argument type and the return type are different. This is because Eigen::internal::result_of cannot handle
the lambda expression correctly, and falling back to the last-resort routine,
in which the return type is assumed as the first argument type.
A comment in the source code says "FIXME, that behavior is a pretty bad hack" so it is worth improving the code.
With assuming C++11, we can replace the implementation of result_of as well as most of other meta-classes in Meta.h with those defined in standard <type_traits> header, which is cleaner and (hopefully) compiled more effiently.
Unfortunately, it turned out that many other codes in Eigen relies on the "bad hack" behavior of the result_of, so we also need to fix these too.
Attached please find a proposed patch (for Eigen 3.2-beta1) that makes the required modification.
With the patch the example can be happily compiled with g++ -std=c++0x, and "make check" results are not so changed (tested with g++ 4.8.0).
I'd appreciate very much if you could include the patch in the next release.
---------------------------------------------------------
#include <Eigen/Dense>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace Eigen;
using namespace std;
int main()
{
Array< string, Dynamic, Dynamic > A(2,3);
A << "123", "234", "456", "345", "789", "567";
auto B = A.unaryExpr( [](string s)-> int { return atoi( s.c_str() ); } );
cout << B << endl;
}
---------------------------------------------------------

Created attachment 323[details]
New Proposed Patch
Sorry, the previous patch was severely broken.
(I just didn't notice that, in make check, my added -std=c++11 is invalidated by -ansi... shame... )
Please find the new patch, which makes a minimal change to the Core/util/Meta.h
Patch includes some change for unsupported sections, which are required to make it compilable with c++11 mode.

I am having this same problem (reported almost three years ago). I can't tell if it's been fixed in one of the versions, but it's not fixed in mine (3.2.0.8), but I did find a good workaround if other googlers end up here:
Wrapping the lambda with std::function<> worked.
i.e.:
auto B = A.unaryExpr( std::function<int(string)>([](string s)-> int { return atoi( s.c_str() ); } ));