Estoy tratando de crear un vector de std :: functions en mi clase logger. Cuando trato de enlazar un método para mi std :: función de esa manera:uso de std bind en C++ para funciones con un argumento (cadena)
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);
la función add_string se define como:
void add_string(string text);
Sin embargo, gcc (con el complemento gfilt para tratar de entender la errores de plantilla) devuelve:
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()' una función miembro de 'NcursesWindows'? – liwp
¿No hay un marcador de posición para el parámetro de cadena que falta en su llamada de enlace? En boost necesitarías 'bind (& NcursesWindow :: add_string, & log_win, _1)' – nabulke
sí, este prototipo de función se toma de NcursesWindows .h – Tuxer