lambdas and std::function template for c++11

The release notes for the recent releases of the compiler mention that they support c++11 lambdas. I have managed to get local lambdas and function pointers to lambdas to work, but the std::function template for passing lambdas with captures seems to be missing, and using the system version causes a pretty huge number of errors.

Is there a compatible standard library that includes std::function or is that something we’ll have to wait for a new release for? (testing with 13.3)

Use" pgcpp --gnu --c++11 "
–c++11 enables the current c++11 support in the compiler
–gnu produces gnu compatible objects and uses the gnu STL which might just have
the lambda template definitions you are looking for.

Note that pgcpp --gnu objects are not link compatible with non-gnu, plain "pgcpp " compiled objects, and all c++ code will need to be recompiled if you go this route.

If this does not do the trick, then please submit a small test example . Full C++ support
is slated by 2014.

Having tried that, unfortunately it did not work. I know the gnu libc on this machine supports it since g++ can compile the code successfully but the header that offers the std::function template is protected behind a check for the GXX_EXPERIMENTAL_CXX0X define. Defining that produces a great deal more errors unfortunately.

There seems to be an implementation in the /opt/pgi… headers too, but it just doesn’t seem to work. Either way, here’s a minimal toy sample that just returns “namespace “std” has no member “function”” on pgcpp with c++11 but works on g++ version 4.6.3 with -std=c++0x.

Clearly I made a mistake submitting early, the example is below.

#include <iostream>
#include <functional>
using namespace std;
int main(int argc, char const *argv[])
{
    std::function<int()> f = []()->int {return 5;};
    return f();
}

Thank you for the small test case. You can track this issue as TPR19283 in our bug system.

The test case also shows that when compiled

pgc++ --c++11 -D__GXX_EXPERIMENTAL_CXX0X__

constexpr has not yet been implemented.

TPR 19283 - pgcpp --c++11 constexpr and function templates not yet implemented
has been implemented in our current 14.4 release.

thanks,
dave