1
Следующего кодаконстантный указатель в качестве параметра станда :: привязки
#include <functional>
#include <iostream>
using namespace std;
struct TestStruct {
int c;
};
int f(int a, int b, const TestStruct **t) { return a + b + (*t)->c; }
void main() {
TestStruct *t;
bind(&f, 1, 2, &t)();
}
сообщает об этой ошибке
error C2893: Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...)'
note: With the following template arguments:
note: '_Callable=int (__cdecl *&)(int,int,const TestStruct **)'
note: '_Types={int &, int &, TestStruct **&}'
кажется, что проблема является константностью в const TestStruct**
паров. Однако нет проблем ни с const TestStruct *
, ни с TestStruct**
. Зачем ?
Вы намеревались написать 'TestStruct ** const'? –
@LightnessRacesinOrbit No. Я упрощен, функция 'f' является внешней функцией' C', с которой я хочу привязываться, и ее подпись такая. – perencia
Вы не можете. http://stackoverflow.com/q/2220916/560648 –