Implements binding and evaluating function declarations

This commit is contained in:
2019-06-01 12:33:52 +02:00
parent c407ba2f50
commit 6936b26cae
11 changed files with 215 additions and 10 deletions

View File

@@ -5,15 +5,17 @@
#include <string>
class HashedString{
int _hash;
static unsigned constexpr const_hash(char const *input) {
return *input ?
static_cast<unsigned int>(*input) + 33 * const_hash(input + 1) :
5381;
}
const int _hash;
public:
explicit HashedString(std::string s){
_hash = const_hash(s.c_str());
explicit HashedString(const std::string& s) : _hash(ConstHash(s.c_str())){
}
explicit HashedString(char const *input) : _hash(ConstHash(input)){
}
static unsigned constexpr ConstHash(char const *input) {
return *input ?
static_cast<unsigned int>(*input) + 33 * ConstHash(input + 1) :
5381;
}
const int GetHash(){