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

Lambda Woes - ICC 14.0 - Linux GCC 4.8.1

Ryan_Goodfellow
Beginner
252 Views

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
252 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

0 Kudos
Reply