我正在将编译器从 Visual Studio 更改为 g++,并且在函数参数中通过引用传递存在一些问题。
在 Visual Studio 中,函数为:
void Foo(int&a, int&b)
以便在此函数中修改 a、b。因此我不能在 g++ 中使用
void Foo(const int&a, const int &b)
而且我的 g++ 中也不允许右值引用:
void Foo( int&& a, int&& b)
那么使用指针是转换代码的唯一方法吗?
void Foo( int* a, int* b)
P/S:这是使用 g++ 编译时的错误:
error: no matching function for call to ‘Steerable::buildSCFpyrLevs(Tensor<double, 2ul>, std::vector<Tensor<double, 2ul> >&, int&, int&, int&, bool&)’
Steerable.cpp:63:100: note: candidate is:
Steerable.h:93:7: note: void Steerable::buildSCFpyrLevs(Steerable::data_ref, std::vector<Tensor<double, 2ul> >&, int, int, int, bool)
Steerable.h:93:7: note: no known conversion for argument 1 from ‘Tensor<double, 2ul>’ to ‘Steerable::data_ref {aka Tensor<double, 2ul>&}’
函数声明是:
typedef Tensor<value_type,2> data_type;
typedef data_type& data_ref;
vector<Steerable::data_type>& Steerable::buildSCFpyr(Steerable::c_data_ref im, int nLevel, int nDir, int twidth, bool subsample)
有错误的行:
buildSCFpyrLevs(imdft.FreqComplexFilter(toComplex(lo0mask)),pyr_freq,nLevel,nDir,twidth, subsample);