为什么std :: bind在使用icc 14.01和gcc 4.8时会出错?

时间:2014-01-30 10:01:51

标签: c++ gcc boost icc odeint

编译这段短代码时遇到问题:

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

#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);

旧代码:

#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 :: bind,std :: function等时出现的一个奇怪的编译器问题(这是真的看到帖子顶部的新代码)

1 个答案:

答案 0 :(得分:2)

我在英特尔论坛here上发布了此问题并得到了以下回复:

  

感谢报道!

     

我们一直在努力,它被追踪为DPD200242895。当修复程序可用时,将更新您。这没有简单的解决方法。对不起。

他们似乎意识到了这个问题,正在制定一个解决方案。希望下一次更新/发布将纠正这一点。

<强>更新

此问题已在版本14.0更新3及更高版本中修复:

  

此问题已在14.0 update 3及更高版本以及15.0中修复。

     

谢谢,   珍