O
OMouse
Hi, I just switched to using STL for my linked lists and obviously I
need a way to insert. I have all the necessary includes (list &
algorithm) and the other functions that I've used (erase & find) work.
But when I try to insert the iterator that was found, gcc 3.3.4 tells
me that I'm missing a few inputs. Anyway, here's the snippet of code.
main.cpp
-----------------
#include "usernode.h"
#include <list>
#include <algorithm>
....
userNode tempNode = userNode(user, pword, NULL, NULL, NULL, false,
NULL);
list<userNode>::iterator listNode;
listNode = find(usersOnline.begin(), usersOnline.end(), tempNode);
if (listNode != usersOnline.end())
{
usersOnline.insert(usersOnline.begin(), listNode);
}
....
-----------------
Error message(s)
-----------------
cd '/home/omouse/cobaltserver/debug' && WANT_AUTOCONF_2_5="1"
WANT_AUTOMAKE_1_6="1" gmake -k -j1
compiling cserver.cpp (g++)
main.cpp:153: error: no matching function for call to
`std::list<userNode, std::allocator<userNode> >::insert(
std::_List_iterator<userNode, userNode&, userNode*>,
std::_List_iterator<userNode, userNode&, userNode*>&)'
/usr/include/c++/3.3.4/bits/list.tcc:88: error: candidates are:
std::_List_iterator<_Tp, _Tp&, _Tp*> std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>, const _Tp&) [with
_Tp = userNode, _Alloc = std::allocator<userNode>]
/usr/include/c++/3.3.4/bits/stl_list.h:831: error: void std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>, unsigned int,
const _Tp&) [with _Tp = userNode, _Alloc = std::allocator<userNode>]
*** Exited with status: 2 ***
need a way to insert. I have all the necessary includes (list &
algorithm) and the other functions that I've used (erase & find) work.
But when I try to insert the iterator that was found, gcc 3.3.4 tells
me that I'm missing a few inputs. Anyway, here's the snippet of code.
main.cpp
-----------------
#include "usernode.h"
#include <list>
#include <algorithm>
....
userNode tempNode = userNode(user, pword, NULL, NULL, NULL, false,
NULL);
list<userNode>::iterator listNode;
listNode = find(usersOnline.begin(), usersOnline.end(), tempNode);
if (listNode != usersOnline.end())
{
usersOnline.insert(usersOnline.begin(), listNode);
}
....
-----------------
Error message(s)
-----------------
cd '/home/omouse/cobaltserver/debug' && WANT_AUTOCONF_2_5="1"
WANT_AUTOMAKE_1_6="1" gmake -k -j1
compiling cserver.cpp (g++)
main.cpp:153: error: no matching function for call to
`std::list<userNode, std::allocator<userNode> >::insert(
std::_List_iterator<userNode, userNode&, userNode*>,
std::_List_iterator<userNode, userNode&, userNode*>&)'
/usr/include/c++/3.3.4/bits/list.tcc:88: error: candidates are:
std::_List_iterator<_Tp, _Tp&, _Tp*> std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>, const _Tp&) [with
_Tp = userNode, _Alloc = std::allocator<userNode>]
/usr/include/c++/3.3.4/bits/stl_list.h:831: error: void std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>, unsigned int,
const _Tp&) [with _Tp = userNode, _Alloc = std::allocator<userNode>]
*** Exited with status: 2 ***