Skip to main content
gamedev.net
🔒 Locked

Error using STL

Started by gama150 0 replies 300+ views
Original Post
gama150
gama150
Hi, I just started using STL. Developing on VC++ and using STL from stlport.org, I get some errors using hash_map. Any help would be appreciated.
  
#include <hash_map>
using namespace std;


class element
{
public:
	element()
	{
	}
	int dummy;

	bool	operator==(const element &ref) const
	{
		return true;
	}
};

class elementComp
{
public:
	bool operator()(element &l, element &r) const
	{
		return true;
	}
};

typedef	hash_map<element, int, elementComp>	Map;


void main(void)
{
	Map		mymap;
	element	e;
	mymap.insert(Map::value_type(e, 1));
}

  
Trying to compile the above code, I get the following errors:
  
c:\program files\microsoft visual studio\stlport\stlport-4.5.3\stlport\stl\_hashtable.h(557) : error C2660: ''()'' : function does not take 1 parameters
        c:\program files\microsoft visual studio\stlport\stlport-4.5.3\stlport\stl\_hashtable.h(556) : while compiling class-template member function ''unsigned int __thiscall _STL::hashtable<struct _STL::pair<class element const ,int>,class element,
class elementComp,struct _STL::_Select1st<struct _STL::pair<class element const ,int> >,struct _STL::equal_to<class element>,class _STL::allocator<struct _STL::pair<class element const ,int> > >::_M_bkt_num_key(const class element &,unsigned int) co
nst''
c:\program files\microsoft visual studio\stlport\stlport-4.5.3\stlport\stl\_hashtable.h(557) : error C2064: term does not evaluate to a function
        c:\program files\microsoft visual studio\stlport\stlport-4.5.3\stlport\stl\_hashtable.h(556) : while compiling class-template member function ''unsigned int __thiscall _STL::hashtable<struct _STL::pair<class element const ,int>,class element,
class elementComp,struct _STL::_Select1st<struct _STL::pair<class element const ,int> >,struct _STL::equal_to<class element>,class _STL::allocator<struct _STL::pair<class element const ,int> > >::_M_bkt_num_key(const class element &,unsigned int) co
nst''
  
The errors occur on this method:
  
  size_type _M_bkt_num_key(const key_type& __key, size_t __n) const
  {
    return _M_hash(__key) % __n;
  }
  

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.