2014-01-30 14 views
1

我编写本一小段代码的问题:为什么std :: bind在使用icc 14.01和gcc 4.8时会出错?

更新: 我有现在生产同样的错误,老人们仍能在帖子的末尾可以看到一个更简单的代码片段。

#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(3); 
    } 

}; 

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

我有它编译罚款一台计算机:

openSUSE 12.3 with gcc 4.7.2 20130108, icc 14.0.1 20131008, boost 1_49 

在此计算机上都

g++ main.cpp -std=c++11 

icc main.cpp -std=c++11 

工作。

在另一台计算机上

openSUSE 13.1 with gcc 4.8.1 20130909 , icc 14.0.1 20131008, boost 1_54 


g++ main.cpp -std=c++11 

作品,但

icc main.cpp -std=c++11 

导致以下错误信息:

main2.cpp(17): error: no instance of overloaded function "std::_Bind<_Functor (_Bound_args...)>::operator() [with _Functor=std::_Mem_fn<double (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<double (Bar::*)(double, double)> (Bar *, double, std::_Placeholder<1>)> 
     function(3); 

OLD CODE:

#include <vector> 

#include "boost/numeric/odeint/stepper/runge_kutta4.hpp" 

using namespace boost::numeric::odeint; 
typedef std::vector<double> state_type; 

class Right_Hand_Side { 
public: 
    void operator()(const state_type &y, state_type &y_dot, const double t) 
    {} 

}; 

int main(int argc, char **argv) { 

    Right_Hand_Side right_hand_side; 
    std::vector<double> state(10); 
    runge_kutta4<state_type> stepper; 
    stepper.do_step(std::ref(right_hand_side), state, 0, 0.1); 

} 

错误消息:

XXX/include/boost/numeric/odeint/util/resizer.hpp(72): error: no instance of overloaded function "std::_Bind<_Functor (_Bound_args...)>::operator() [with _Functor=std::_Mem_fn<bool (boost::numeric::odeint::explicit_stepper_base<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, (unsigned short)4U, 
      state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>::*)(const std::vector<double, std::allocator<double>> &)>, _Bound_args=<std::reference_wrapper<boost::numeric::odeint::explicit_stepper_base<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, 
      boost::numeric::odeint::initially_resizer>, (unsigned short)4U, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>>, std::_Placeholder<1>>]" matches the argument list 
      argument types are: (const std::vector<double, std::allocator<double>>) 
      object type is: std::_Bind<std::_Mem_fn<bool (boost::numeric::odeint::explicit_stepper_base<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, (unsigned short)4U, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, 
         boost::numeric::odeint::initially_resizer>::*)(const std::vector<double, std::allocator<double>> &)> (std::reference_wrapper<boost::numeric::odeint::explicit_stepper_base<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, (unsigned short)4U, state_type, double, state_type, double, 
         boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>>, std::_Placeholder<1>)> 
       return f(x); 
        ^
      detected during: 
      instantiation of "bool boost::numeric::odeint::initially_resizer::adjust_size(const State &, ResizeFunction) [with State=std::vector<double, std::allocator<double>>, ResizeFunction=std::_Bind<std::_Mem_fn<bool (boost::numeric::odeint::explicit_stepper_base<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, (unsigned 
         short)4U, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>::*)(const std::vector<double, std::allocator<double>> &)> (std::reference_wrapper<boost::numeric::odeint::explicit_stepper_base<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, 
         boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, (unsigned short)4U, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>>, std::_Placeholder<1>)>]" at line 196 of "XXX//include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp" 
      instantiation of "void boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::do_step_v1(System, StateInOut &, boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type, boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type) [with 
         Stepper=boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, Order=(unsigned short)4U, State=state_type, Value=double, Deriv=state_type, Time=double, Algebra=boost::numeric::odeint::range_algebra, Operations=boost::numeric::odeint::default_operations, Resizer=boost::numeric::odeint::initially_resizer, 
         System=std::reference_wrapper<Right_Hand_Side>, StateInOut=std::vector<double, std::allocator<double>>]" at line 113 of "XXX//include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp" 
      instantiation of "void boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::do_step(System, StateInOut &, boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type, boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type) [with 
         Stepper=boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, Order=(unsigned short)4U, State=state_type, Value=double, Deriv=state_type, Time=double, Algebra=boost::numeric::odeint::range_algebra, Operations=boost::numeric::odeint::default_operations, Resizer=boost::numeric::odeint::initially_resizer, 
         System=std::reference_wrapper<Right_Hand_Side>, StateInOut=std::vector<double, std::allocator<double>>]" at line 21 of "main.cpp" 

XXX//include/boost/numeric/odeint/util/resizer.hpp(72): error: no instance of overloaded function "std::_Bind<_Functor (_Bound_args...)>::operator() [with _Functor=std::_Mem_fn<bool (boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>::*)(const std::vector<double, std::allocator<double>> &)>, 
      _Bound_args=<std::reference_wrapper<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>>, std::_Placeholder<1>>]" matches the argument list 
      argument types are: (const std::vector<double, std::allocator<double>>) 
      object type is: std::_Bind<std::_Mem_fn<bool (boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>::*)(const std::vector<double, std::allocator<double>> &)> (std::reference_wrapper<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, 
         boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>>, std::_Placeholder<1>)> 
       return f(x); 
        ^
      detected during: 
      instantiation of "bool boost::numeric::odeint::initially_resizer::adjust_size(const State &, ResizeFunction) [with State=std::vector<double, std::allocator<double>>, ResizeFunction=std::_Bind<std::_Mem_fn<bool (boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>::*)(const std::vector<double, std::allocator<double>> 
         &)> (std::reference_wrapper<boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>>, std::_Placeholder<1>)>]" at line 146 of "XXX//include/boost/numeric/odeint/stepper/explicit_generic_rk.hpp" 
      instantiation of "void boost::numeric::odeint::explicit_generic_rk<StageCount, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::do_step_impl(System, const StateIn &, const DerivIn &, boost::numeric::odeint::explicit_generic_rk<StageCount, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type, StateOut &, boost::numeric::odeint::explicit_generic_rk<StageCount, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type) [with 
         StageCount=4UL, Order=4UL, State=state_type, Value=double, Deriv=state_type, Time=double, Algebra=boost::numeric::odeint::range_algebra, Operations=boost::numeric::odeint::default_operations, Resizer=boost::numeric::odeint::initially_resizer, System=std::reference_wrapper<Right_Hand_Side>, StateIn=std::vector<double, std::allocator<double>>, DerivIn=state_type, StateOut=std::vector<double, std::allocator<double>>]" at line 198 of 
         "XXX//include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp" 
      instantiation of "void boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::do_step_v1(System, StateInOut &, boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type, boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type) [with 
         Stepper=boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, Order=(unsigned short)4U, State=state_type, Value=double, Deriv=state_type, Time=double, Algebra=boost::numeric::odeint::range_algebra, Operations=boost::numeric::odeint::default_operations, Resizer=boost::numeric::odeint::initially_resizer, 
         System=std::reference_wrapper<Right_Hand_Side>, StateInOut=std::vector<double, std::allocator<double>>]" at line 113 of "XXX//include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp" 
      instantiation of "void boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::do_step(System, StateInOut &, boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type, boost::numeric::odeint::explicit_stepper_base<Stepper, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer>::time_type) [with 
         Stepper=boost::numeric::odeint::explicit_generic_rk<4UL, 4UL, state_type, double, state_type, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, Order=(unsigned short)4U, State=state_type, Value=double, Deriv=state_type, Time=double, Algebra=boost::numeric::odeint::range_algebra, Operations=boost::numeric::odeint::default_operations, Resizer=boost::numeric::odeint::initially_resizer, 
         System=std::reference_wrapper<Right_Hand_Side>, StateInOut=std::vector<double, std::allocator<double>>]" at line 21 of "main.cpp" 

compilation aborted for main.cpp (code 2) 

我有一种感觉,这是什么的boost :: odeint具体的,而是一个奇怪的编译器的问题,来了使用std ::绑定,性病::等功能时(这是真的看到新的代码在后的顶部)

+1

这些ICC版本号不正确? –

+0

升压版本是否一样?他们是什么? – Silex

+0

@TristanBrindle:复制和粘贴的危险。更正了icc版本 – user1304680

回答

2

我贴在英特尔论坛here这个问题,并得到了以下回应:

感谢您报告吧!

我们一直在研究它,它被作为DPD200242895进行跟踪。将在修复程序可用时更新您。对此没有简单的解决方法。对于那个很抱歉。

看来他们已经意识到了这个问题并正在研究解决方案。希望下一次更新/发布会纠正这个问题。

UPDATE:

此问题已得到修复版本14.0 Update 3及更高版本:

此问题被固定在14.0 Update 3及更高版本,以及15.0。

感谢, 詹妮弗

相关问题