Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ryan_Goodfellow
Beginner
71 Views

Lambda Woes - ICC 14.0 - Linux GCC 4.8.1

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

0 Kudos
1 Reply
Judith_W_Intel
Employee
71 Views

 

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

Reply