5
我试图在我的记录器类中创建std :: functions的向量。当我尝试结合的方法,以我的std ::函数那样:在C++中使用std绑定函数的参数(字符串)
NcursesWindow log_win("Logs",LINES-1,COLS/3,0,COLS*2/3);
std::function<void(std::string)> f = std::bind(&NcursesWindow::add_string,&log_win);
的add_string功能被定义,如:
void add_string(string text);
然而,海湾合作委员会(与gfilt插件,试图了解模板错误)返回:
BD Software STL Message Decryptor v3.10 for gcc 2/3/4
In file included from ./inc/ncursesui.h:6:0,
from src/ncursesui.cpp:1:
functional: In static member function ‘static void _Function_handler<
void({basic_string<char>} ...), _Bind<
_Mem_fn<void (NcursesWindow::*)(basic_string<char>)>(
NcursesWindow)>
>::_M_invoke(const _Any_data &, {basic_string<char>} ...)’:
[STL Decryptor: Suppressed 1 more STL standard header message]
src/ncursesui.cpp:32:86: instantiated from here
functional:1778:2: erreur: no match for call to ‘(
_Bind<
_Mem_fn<void (NcursesWindow::*)(basic_string<char>)>(
NcursesWindow)>) (basic_string<char>)’
STL Decryptor reminders:
Use the /hdr:L option to see all suppressed standard lib headers
Use the /cand:L option to see all suppressed template candidates
'add_string()'NcursesWindows'的成员函数吗? – liwp 2012-02-09 14:28:57
在绑定调用中缺少字符串参数的占位符吗?在boost中,你需要'bind(&NcursesWindow :: add_string,&log_win,_1)' – nabulke 2012-02-09 14:33:05
是的,这个函数原型取自NcursesWindows .h – Tuxer 2012-02-09 14:36:53