News for hackers. Stuff that matters.
Re:Show HN: C++11 immutable string by thegeomaster on Wednesday June 04, 2014 @03:40AM (#7844421)
Great job. I like it how peole are moving to and developing for C++11 as I think it's a huge step forward in the standard. The one cosmetic complaint I have is that the slicing syntax is not verbose enough for my taste. Also, what hash algo did you use? Asking just out of curiosity. I remember running a benchmark a long ago of different non-cryptographic hashes. The collision resistance was pretty consistent across all of them, but some were really slow and some were really fast, and that could directly affect the performance on hashtables and other structures that rely on hashes.
Re:Show HN: C++11 immutable string by syvex on Wednesday June 04, 2014 @09:12AM (#7845325)
The hash is FNV-1a, which should be faster that what you usually get in your standard library. It's also relatively easy to implement with constexpr so that you get those nice compile time hashes.

http://www.isthe.com/chongo/tech/comp/fnv/

Re:Show HN: C++11 immutable string by syvex on Wednesday June 04, 2014 @09:20AM (#7845355)
I can't say I'm 100% happy with the slicing notation. I played around with some other wacky things, but then settled on overloading operator() to get a concise syntax.

In principle, you use it similar to python--s(5,10) instead of s[5:10].

I would have maybe liked to end up with s[5,10], but the only way to overload operator[] like that is with a pair. Then you'd end up with s[{5,10}]. So I figured it would be best to stick with just s(5,10).

Re:Show HN: C++11 immutable string by thegeomaster on Wednesday June 04, 2014 @07:57PM (#7849253)
Not relevant in this case, but you may find this interesting (assuming you haven't seen it already): https://github.com/klmr/named-operator.