Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7954 Discussions

function objects to capture lambda functions in C++

Yuan_Tang
Beginner
501 Views
Hi,

as you know, lambda function in C++ could be captured by 2 options:

1) auto keyword

2) function object such as following:
#include 
using namespace std; function f2 = [] (int x, int y) { return x + y; };
But when I compile this code with icc-12(beta), it will complain:

tb_pochoir.hpp(62): error: function is not a template
function f2;
^
Would you tell me why? and how to fix this problem?

Thanks!

-Yuan

0 Kudos
5 Replies
Brandon_H_Intel
Employee
501 Views
Which version of Visual Studio* are you using? The problem might be in the Microsoft STL support. This works for me with the Intel compiler integrated with Visual Studio 2010*.
0 Kudos
Yuan_Tang
Beginner
501 Views
Brandon,

I'm using icc-12 (beta) version under linux. So, there's no visual studio. Just icc.

Would you give me some idea how to fix this problem?

Thanks!

-(\x.x x) (\x.x x)
0 Kudos
Brandon_H_Intel
Employee
501 Views
Hi Yuan,

We don't support variadic templates yet in the compiler. I've linked this thread to an open request for that support, and when I have any more news, I will update this thread. Unfortunately, there's no workarounds at this point to get this to work without that support.
0 Kudos
Brandon_H_Intel
Employee
501 Views
0 Kudos
Brandon_H_Intel
Employee
501 Views
This problem is resolved in the version 12.1 compiler available in Intel C++ Composer XE 2011 update 6 and above.
0 Kudos
Reply