I'm having a problem with using templates, and since I'm completely at a loss as to what's wrong, I'm simply going to dump the (I think) relevant sections of code here.
Here is the problem code:
The bolded line is the one throwing the error.
Here is the compiler error:Code:#include <vector> #include <algorithm> using namespace std; template<class client_type> class ServiceList { public: /* blah blah blah... */ // move a client off the to-serve list void signOut(client_type & targ) { signOut(&targ); }; void signOut(client_type * const targ) { // find the given client pointer in our list vector<client_type *>::iterator where = find(client_list.begin(),client_list.end(), targ); // if it's in there, delete it! if (where != client_list.end()) client_list.erase(where); }; /* more blah... */ protected: // the list of pointers to clients vector<client_type *> client_list; };
The bolded line refers to the bolded bit in the code segment I posted.Code:In file included from KeyDispatcher.hpp:7, from ProtPlay.hpp:4, from Follower.hpp:4, from Follower.cpp:1: ServiceList.hpp: In member function `void ServiceList<client_type>::signOut(client_type*)': ServiceList.hpp:26: error: expected `;' before "where" ServiceList.hpp:30: error: `where' undeclared (first use this function) ServiceList.hpp:30: error: (Each undeclared identifier is reported only once for each function it appears in.)
By the way, I'm using Dev-C++ 4.9.9.2.
As I said, I don't know what's wrong at all. Help me, please?
And if you have some clever suggestions about the implementation in general, feel free to state them. This class is a template class to use in creating a message-dispatching class. Specifically, I'm currently using it to dispatch keyboard messages to a bunch of character queues. The class keeps a vector of pointers to the client character queues, and the child class of ServiceList will specify a function to actually dispatch the messages by iterating through the vector. I decided on a vector because I don't care (at least, not now) about signin/signout speeds, just the time it takes to dispatch a message.
So, yeah. You.Help(Me); ?



LinkBack URL
About LinkBacks


