Problème for_each et foncteur personnel
Bonsoir,
J'ai un petit problème dans mon code.
Petit problème avec for_each et un foncteur ...
Voici le code :
Code:
1 2 3 4 5 6 7 8 9
| template <class T> struct print
{
print(QListWidget& lw) : os(lw) {}
void operator() (T& x) { os.addItem(x.c_str()); }
QListWidget& os;
};
// ...
list = new QListWidget;
std::for_each(v.begin(),v.end(),print<std::string>(list)); |
v étant un vector<std::string>.
Dev-C++ me raconte :
Citation:
win.cpp:19: error: no matching function for call to `print<std::string>::print(QListWidget*&)'
win.cpp:6: note: candidates are: print<std::string>::print(const print<std::string>&)
win.cpp:7: note: print<T>::print(QListWidget&) [with T = std::string]
Je ne comprends pas pourquoi il ne se sert pas de : print<T>::print(QListWidget&) [with T = std::string]
Merci de votre attention.