나는 다음과 같은 유형을받는 여러 가지 기능을 가지고 :C++ : - 표준 : : 바인딩> 표준 : 기능
array2D
사용자 정의 유형이다
function<double(int,int,array2D<vector<double *>>*)>
. 또한, 내가 인수로 다음받는 함수가 : 올바른 서명이 펑터를 첫 번째 값, temp
을 결합, 반환하기 위해, 지금
double ising_step_distribution(double temp,int i,int j,array2D<vector<double *>>* model)
을, 나는 쓰고 :
double temp = some_value;
function<double(int,int,array2D<vector<double *>>*)> step_func =
[temp](int i, int j, array2D<vector<double *>>* model){
return ising_step_distribution(temp,i,j,model);
}
}
그리고이 방법이 효과적입니다. 그러나 다음 휴식 : 다음 오류
auto step_func =
[temp](int i, int j, array2D<vector<double *>>* model){
return ising_step_distribution(temp,i,j,model);
}
}
는 :
candidate template ignored:
could not match
'function<double (int, int, array2D<vector<type-parameter-0-0 *, allocator<type-parameter-0-0 *> > > *)>'
against
'(lambda at /Users/cdonlan/home/mcmc/main.cpp:200:25)'
void mix_2D_model(function<double(int,int,array2D<vector<T*>>*)> step_distribution_func,...
그래서, 코드 덩어리가, 추한 obfuscative 반복적 인
는 (나는이 많이 제작하고 있기 때문에).내가 설명서를 읽고 있고, 내가 쓸 수 있어야 이해 :
function<double(int,int,array2D<vector<double *>>*)> step_func =
bind(ising_step_distribution,temp,_1,_2,_3);
그러나 내가 본 한
만 예는 유형
function<void()>
의 기능입니다. 이 오류는 다음 오류로 인해 실패합니다.
// cannot cast a bind of type
// double(&)(double,int,int,array2D<vector<double *>>*)
// as function<double(int,int,...)
시각적으로 깨끗한 바인딩 및 캐스트를 얻으려면 어떻게해야합니까?
두 번째 람다 무엇 에러가 발생합니까? 람다는 거의 항상'std :: bind'에 우선합니다; 가능한 경우 람다 (lambda) 버전을 사용하도록 노력할 것입니다. – 0x5453
@ 0x5453 아, 그래. 1 초, 다시 실행합니다. – bordeo
@ 0x5453 오류가 발생했습니다. 'array2D> *' –
bordeo