| View previous topic :: View next topic |
| Author |
Message |
njustn
Joined: 09 Nov 2011 Posts: 18
|
Posted: Tue Apr 09, 2013 6:43 am Post subject: 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) |
|
| Back to top |
|
 |
Deborah Caruso
Joined: 20 Oct 2004 Posts: 43
|
Posted: Tue Apr 09, 2013 2:24 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
njustn
Joined: 09 Nov 2011 Posts: 18
|
Posted: Fri Apr 12, 2013 12:24 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
njustn
Joined: 09 Nov 2011 Posts: 18
|
Posted: Fri Apr 12, 2013 12:38 pm Post subject: |
|
|
Clearly I made a mistake submitting early, the example is below.
| Code: |
#include <iostream>
#include <functional>
using namespace std;
int main(int argc, char const *argv[])
{
std::function<int()> f = []()->int {return 5;};
return f();
}
|
|
|
| Back to top |
|
 |
Deborah Caruso
Joined: 20 Oct 2004 Posts: 43
|
Posted: Fri Apr 12, 2013 1:57 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|