"class std::map used without template paramaters" error

c++, gcc, stl

Solution

Replace `std::map::end` with `_ldapClientMap.end()`. Also, `new` never returns 0, it throws an exception if the allocation fails.

Note that the program can be made much shorter.

LdapClient * LdapClientManager::getLdapClient(unsigned int templateID)
{
    LdapClient *& value = _ldapClientMap[templateID];
    if (value == 0)
        value = new LdapClient();
    return value;
}

Problem

I'd have to say I'm no expert on using the STL. Here's my problem, I have a class Called LdapClientManager which maintains a number of LDAP clients that are managed by ID. The container holding the LdapClients is declared as a member variable i.e. ``` typedef std::map<int, LdapClient *> LdapClientMap; LdapClientMap _ldapClientMap; ``` The following function fails to compile with the error: ``` LdapClient * LdapClientManager::getLdapClient(unsigned int templateID) { // Do we have an LdapClient LdapClientMap::const_iterator it = _ldapClientMap.find(templateID); if (it == std::map::end) { // no existing client, lets create it LdapClient * ldapClient = new LdapClient(); if (ldapClient == NULL) { // TODO: handle out of memory condition } _ldapClientMap[templateID] = ldapClient; return ldapClient; } return it->second; } ``` Unfortunately I get the following error at compile time, what does it mean. I haven't found a solution in google as yet. LdapClientManager.cc: In member function `LdapClient* LdapClientManager::getLdapClient(unsigned int)': LdapClientManager.cc:33:`template class std::map' used without template parameters

Original source