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

Problems with std::bind when using gcc 4.8.0 with icc 14.0.1.

peter_b_
Beginner
381 Views

Hi there,

I have problems compiling the following code where a public method foo2 of class Bar uses std::bind on another such method foo. I am using icc 14.0.1 20131008 and gcc 4.8.0

//compile with: icc main.cpp -std=c++11
#include <vector>
#include <iostream>
#include <functional>

class Bar {

public:
  void foo(double x, double y) {
      std::cout << x << std::endl;
      std::cout << y << std::endl;
  }
  
  void foo2(double x) {
    using namespace std::placeholders;
    auto function = std::bind(&Bar::foo, this, x, _1);
    function(0);
  }
  
};

int main(int argc, char **argv) {
  Bar bar;
  bar.foo2(1);
}

The error message reads:

 error: no instance of overloaded function "std::_Bind<_Functor (_Bound_args...)>::operator() [with _Functor=std::_Mem_fn<void (Bar::*)(double, double)>, _Bound_args=<Bar *, double, std::_Placeholder<1>>]" matches the argument list
            argument types are: (int)
            object type is: std::_Bind<std::_Mem_fn<void (Bar::*)(double, double)> (Bar *, double, std::_Placeholder<1>)>
      function(0);

I am not having this problem using the same Intel Compiler but with gcc 4.7.2 instead

Thanks for your help!

 

 

 

I am using icc 14.0.1 20131008 and

gcc 4.7.2 20130108, icc 14.0.1 20131008, boost 1_49

 

0 Kudos
1 Reply
peter_b_
Beginner
381 Views

sorry for the bad formatting and please ignore the last two lines

 

0 Kudos
Reply