language: C++11 (gcc-4.7.2)
date: 261 days 2 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <vector>
#include <stdint.h>
 
constexpr uint64_t do_the_hash(const char* input, uint64_t value_so_far) {
    return *input ? do_the_hash(input + 1, (value_so_far << 8) | *input) : value_so_far;
}
 
 
constexpr uint64_t hash_metafunction(const char* input) {
    return do_the_hash(input, 0);
}
 
int main()
{
    std::cout << std::hex;
    std::cout << hash_metafunction("a") << std::endl;
    std::cout << hash_metafunction("ab") << std::endl;
    std::cout << hash_metafunction("abc") << std::endl;
}