2014-01-30 21 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。

感謝, 詹妮弗

相關問題