PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

lambdas and std::function template for c++11
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
njustn



Joined: 09 Nov 2011
Posts: 22

PostPosted: Tue Apr 09, 2013 6:43 am    Post subject: lambdas and std::function template for c++11 Reply with quote

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
View user's profile
Deborah Caruso



Joined: 20 Oct 2004
Posts: 43

PostPosted: Tue Apr 09, 2013 2:24 pm    Post subject: Reply with quote

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
View user's profile
njustn



Joined: 09 Nov 2011
Posts: 22

PostPosted: Fri Apr 12, 2013 12:24 pm    Post subject: Reply with quote

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
View user's profile
njustn



Joined: 09 Nov 2011
Posts: 22

PostPosted: Fri Apr 12, 2013 12:38 pm    Post subject: Reply with quote

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
View user's profile
Deborah Caruso



Joined: 20 Oct 2004
Posts: 43

PostPosted: Fri Apr 12, 2013 1:57 pm    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group