- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am pretty sure the following program complies to C++ 0x standard. icc however cannot compile it:
#include <functional>
struct Node {
size_t length;
};
template<typename N>
class C {
public:
size_t longest = 0;
std::function<void(const N )> f = [this](N node) {
if(node->length > this->longest) this->longest = node->length;
};
};
int main() {
Node n;
n.length = 5;
C<Node*> c;
c.f(&n);
}
The error is:
test_func.cc(12): error: "this" cannot be used inside the body of this lambda
if(node->length > this->longest) this->longest = node->length;
I compile with icc (ICC) 14.0.2 20140120 using -std=c++11 option
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I think you are correct. Both clang and Microsoft accept this (GNU gives an internal error).
It looks like our compiler gives an error because the use of "this" is not inside a non static member function (which I think is ok here).
I have entered DPD200257106 in our internal tracking database to track this defect. Thank you for bringing it to our attention.
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Judy, I've updated the issue id to the thread for tracking purposes as well....
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page