HN user

joejoint

8 karma
Posts0
Comments7
View on HN
No posts found.

Next to the name and age it's the profession. Here are some you think should not be allowed to vote.

Anna, 24 - Student. Alessandro, 30 - Doctor. Federico, 32 - Professor. Martino, 27 - Doctor.

Why not just hash the string using constexpr ?

====================

C preprocessor based compile time hash from lolengine:

http://lolengine.net/blog/2011/12/20/cpp-constant-string-has...

====================

#define H1(s,i,x)(x65599u+(uint8_t)s[(i) <strlen(s)?strlen(s)-1-(i):strlen(s)])

#define H4(s,i,x) H1(s,i,H1(s,i+1,H1(s,i+2,H1(s,i+3,x))))

#define H16(s,i,x) H4(s,i,H4(s,i+4,H4(s,i+8,H4(s,i+12,x))))

#define H64(s,i,x) H16(s,i,H16(s,i+16,H16(s,i+32,H16(s,i+48,x))))

#define H256(s,i,x) H64(s,i,H64(s,i+64,H64(s,i+128,H64(s,i+192,x))))

#define HASH(s) ((uint32_t)(H256(s,0,0)^(H256(s,0,0)>>16)))

template<size_t N> constexpr uint32_t h(char const (&s)[N]) { return HASH(s); }

constexpr uint32_t h(const char s) { return HASH(s); }

uint32_t h(const std::string& s) { return h(s.c_str()); }

int main(int argc, const char argv) {

    auto s = "keep";
    std::string x = "simple";

    switch(h(x))
    {
        case h("keep")  : std::cout << "keep"; break;
        case h("it")    : std::cout << "it"; break;
        case h("simple"): std::cout << "simple"; break;

    };

Personally when I book an holiday I do that well in advance (4 to 6 months) trying to get a good deal. Most of the time cancel an holiday is expensive. Back in October I was looking for a ski holiday and looked at Denver, what put me off was not the possibility of Trump or Clinton be the president but the dollar vs pound. I do believe that one main reason for the decline in this period was the strong dollar appreciation against other currencies back in Nov/Dec. For many holidays travellers, economic reasons count more then political reasons when choosing the holiday destination.

Said that I'm going next week to Chicago.