fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <stdint.h>
  4.  
  5. constexpr uint64_t do_the_hash(const char* input, uint64_t value_so_far) {
  6. return *input ? do_the_hash(input + 1, (value_so_far << 8) | *input) : value_so_far;
  7. }
  8.  
  9.  
  10. constexpr uint64_t hash_metafunction(const char* input) {
  11. return do_the_hash(input, 0);
  12. }
  13.  
  14. int main()
  15. {
  16. std::cout << std::hex;
  17. std::cout << hash_metafunction("a") << std::endl;
  18. std::cout << hash_metafunction("ab") << std::endl;
  19. std::cout << hash_metafunction("abc") << std::endl;
  20. }
  21.  
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
61
6162
616263