Strange Behevior when trying to create a Template containing maps
Hi all, i'm new to Templates and when i tried to implement templates methods which needs to use a map (which is a member in private), the map can only do 3 things: insert, swap, and operator =. and i don't get the full functionality of map..
Here's the code:
#ifndef __GARAGE_H_
#define __GARAGE_H_
#include <map>
using namespace std;
template <class T,class SortKey, class SearchKey>
class GarageDataBase
{
public :
GarageDataBase();
virtual ~GarageDataBase();
const T& Top() const;
bool Add(T data,SortKey key2, SearchKey key2);
T Remove(SearchKey toRemove);
T Find(SearchKey toFind) const;
bool isEmpty()const;
private:
multimap<SortKey,T> firstMap;
multimap<SearchKey,pair<SortKey,T>*> secondMap;
};
#endif
template <class T,class SortKey, class SearchKey> GarageDataBase<T,SortKey,SearchKey>::GarageDataBase()
{
}
template <class T,class SortKey, class SearchKey> GarageDataBase<T,SortKey,SearchKey>::~GarageDataBase()
{
}
template <class T,class SortKey, class SearchKey> const T& GarageDataBase<T,SortKey,SearchKey>::Top() const
{
firstMap.
}
in the last func when trying to get into firstMap mathods, all i get is: insert, swap or, =...
I would not expect code completion to work flawlessly in the presence of templates, because in general it's not possible to know for certain what types are involved. What happens if you enter by hand the statement I suggested and compile it?
The trouble is that in general, when the type of an object includes a template parameter, it is not always possible to determine what all of its members are.