I have a template class for thread-safe vector:
template <class T>
class SharedVector {
std::vector<T> vect;
CRITICAL_SECTION cs;
SharedVector(const SharedVector<T>& rhs) {}
public:
typedef typename std::vector<T>::size_type SizeType;
SharedVector();
void PushBack(const T& value);
void PopBack();
SizeType size();
const T& operator[](int index);
void erase(int index);
void Lock();
void Unlock();
virtual ~SharedVector();
};
Then I want to use it in my client manager for TCP server to delegate some responsibilities from client manager to this vector:
class TCPClientManager {
TCPClientManager(const TCPClientManager&) {}
TCPClientManager& operator=(const TCPClientManager&) {}
SharedVector<Connection*> connections;
public:
TCPClientManager();
SharedVector<>::SizeType size(); //here is the problem
void addConnection(const Client&);
void breakConnection(int);
void deleteConnection(int);
void Lock();
void Unlock();
~TCPClientManager();
};
typename SharedVector<>::SizeType TCPClientManager::size() {
return connections.size();
}
I need to declare the type of retrieving value. Compiler said that it was too few arguments for template.