B
Billy Patton
First, I'm not a student looking for help. Although there's nothing wrong
with studens looking for help here.
I'm learning c++ move further away from the perl wars here at
work (my version is better, use it only)
I've had this HashTable written in c that I've used for 10+ years. It works
without any problems. I'm trying to reduce my overall amount of code by using
STL in c++. To make migration easier I've create a class that inherits the map
class and made the whole thing into a template. I've kept my original function
calls to make my life easier.
Here's my efforts so far :
template <typename K,typename V> class HashTable: public std::map<K,V>
{
public:
bool Put(K&,V&,bool replace=false)
{
if (replace)
this->erase(K); <<<<<<< LINE# 79
return (this->insert(make_pair(K,V))) ? true : false;
}
V& Value(K&) { }
bool Keys(K&,bool firstp = false) { }
bool Exists(K&) { }
void DumpKeys(void) { }
unsigned int EntryCount(void) { return this->size(); }
};
My test_script so far :
#include "include/HashTable.h"
#include <string>
using namespace std;
int main(void)
{
HashTable<std::string,std::string> shash;
HashTable<int,int> ihash;
HashTable<char*,char*> chash;
return 0;
}
The results of my compile:
[bpatton@holster07 cdmg_toolbox]$ g++ -o x x.cxx
In file included from x.cxx:1:
include/HashTable.h: In member function `bool HashTable<K, V>:
ut(K&, V&,
bool)':
include/HashTable.h:79: error: expected primary-expression before ')' token
include/HashTable.h:80: error: expected primary-expression before ',' token
include/HashTable.h:80: error: expected primary-expression before ')' token
include/HashTable.h:80: error: there are no arguments to `make_pair' that
depend on a template parameter, so a declaration of `make_pair' must be
available
include/HashTable.h:80: error: (if you use `-fpermissive', G++ will accept your
code, but allowing the use of an undeclared name is deprecated)
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, (e-mail address removed)
with studens looking for help here.
I'm learning c++ move further away from the perl wars here at
work (my version is better, use it only)
I've had this HashTable written in c that I've used for 10+ years. It works
without any problems. I'm trying to reduce my overall amount of code by using
STL in c++. To make migration easier I've create a class that inherits the map
class and made the whole thing into a template. I've kept my original function
calls to make my life easier.
Here's my efforts so far :
template <typename K,typename V> class HashTable: public std::map<K,V>
{
public:
bool Put(K&,V&,bool replace=false)
{
if (replace)
this->erase(K); <<<<<<< LINE# 79
return (this->insert(make_pair(K,V))) ? true : false;
}
V& Value(K&) { }
bool Keys(K&,bool firstp = false) { }
bool Exists(K&) { }
void DumpKeys(void) { }
unsigned int EntryCount(void) { return this->size(); }
};
My test_script so far :
#include "include/HashTable.h"
#include <string>
using namespace std;
int main(void)
{
HashTable<std::string,std::string> shash;
HashTable<int,int> ihash;
HashTable<char*,char*> chash;
return 0;
}
The results of my compile:
[bpatton@holster07 cdmg_toolbox]$ g++ -o x x.cxx
In file included from x.cxx:1:
include/HashTable.h: In member function `bool HashTable<K, V>:
bool)':
include/HashTable.h:79: error: expected primary-expression before ')' token
include/HashTable.h:80: error: expected primary-expression before ',' token
include/HashTable.h:80: error: expected primary-expression before ')' token
include/HashTable.h:80: error: there are no arguments to `make_pair' that
depend on a template parameter, so a declaration of `make_pair' must be
available
include/HashTable.h:80: error: (if you use `-fpermissive', G++ will accept your
code, but allowing the use of an undeclared name is deprecated)
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, (e-mail address removed)