- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using ICC,
icc --version
icc (ICC) 14.0.1 20131008
`icc -std=c++11 test.cpp -o test`
the following code for test.cpp compiles
[cpp]
#include <functional> #include <string> struct widget {}; struct some_obj { std::function<widget(std::string, int)> f1() { return [this](std::string, int val) { return widget{}; }; } }; int main(){}
[/cpp]
so does this:
[cpp]
#include <functional> #include <string> struct widget {}; struct some_obj { std::function<widget(double)> f2() { return [this](double d) { return widget{}; }; } }; int main(){}
[/cpp]
but not this:
[cpp]
#include <functional> #include <string> struct widget {}; struct some_obj { std::function<widget(std::string, int)> f1() { return [this](std::string, int val) { return widget{}; }; } std::function<widget(double)> f2() { return [this](double d) { return widget{}; }; } }; int main() {}
[/cpp]
the error is this:
[plain]
test.cpp(17): error: no suitable user-defined conversion from "lambda [](double)->widget" to "std::function<widget (double)>" exists
return [this](double d) { return widget{}; };
[/plain]
In words, the class some_obj compiles with either function f1 or f2 as members but not both. All versions of this code work on both clang++3.4 and g++4.8 on the same platform with the same flags using the same standard library (libstdc++4.8.1).
Are lambdas not fully supported yet?
Thanks ~ ry
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ryan,
This appears to be fixed in our latest 14.0 update (update 2). This should be released shortly.
Sorry for the trouble.
Judy
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page