Questions tagged [stdhash]

c++11 library to ease hashing of user-defined types

API Reference: http://en.cppreference.com/w/cpp/utility/hash

59 questions
0
votes
2 answers

std::hash with a pointer and a byte size

I've got a variable size binary data blob that is accessible through a std::byte pointer and a byte size. Is there a way to call std::hash on it? (I can't find any example for this)
moala
  • 5,094
  • 9
  • 45
  • 66
0
votes
0 answers

How to use std::hash to hash data by chunks and not all together?

I am learning about std::hash and I would like to make a program that hashes a file, even if that file is large. I don't want to load that entire file in memory, I'd rather just hash individual chunks and then somehow hash the hashes. I understand…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
0
votes
1 answer

How to pass reference type to std::hash

I am creating a Template Cache library in C++-11 where I want to hash the keys. I want to use default std::hash for primitive/pre-defined types like int, std::string, etc. and user-defined hash functions for user-defined types. My code currently…
0
votes
0 answers

Using union for structure hashing with std::unordered_map or std::unordered_set

I have a simple structure: struct data { bool flag; std::size_t ix; std::size_t iy; std::size_t d; }; I keep all instances of this structure in container, and I need to search it as fast as possible. At the moment I use the std::set with…
one_two_three
  • 501
  • 2
  • 10
0
votes
1 answer

Why this code provides specialization for **ALL** enums for std::hash template?

I'm not a pro in C++ but somehow I provided a solution while porting my MSVS 2015 C++ code to MinGW 4.9.2 to specialize std::hash class to support all enums. It there's any C++ compiler developers or C++ pro programmers here, can you explain why…
0
votes
1 answer

Compile error when using std::hash; does not name a template type

I am receiving the error "hashmap.hpp:63:14: error: ‘hash’ in namespace ‘std’ does not name a template type std::hash hash;" I don't understand why i need to implement my own specialization when I'm passing in type T, which will probably be one…
Adele
  • 39
  • 2
  • 9
0
votes
2 answers

Inner scoped enumeration, hash function and unordered_set data member

I've the following problem of which I cannot find a solution. Of course, it could be that a solution does not exist at all, but I'd like to have a try on SO before to give up. First of all, a snippet that compiles with no errors: #include…
skypjack
  • 49,335
  • 19
  • 95
  • 187
0
votes
3 answers

Unable to Use Specialization of std::hash for Pointer-to-Member?

I assume that std::hash's specialization for generic pointer types can be used for pointer-to-members, however I am unable to use it as such; instead, my compiler gives me an "incomplete type" error, which I assume means that is' not using the…
Shokwav
  • 654
  • 8
  • 19
0
votes
1 answer

c++ std::hash specilization trait compile error

hi i am tryng to implement a trait class of std::hash struct but i cannot progress from here: #include #include namespace std { template<> struct hash< Test::AckMsgType > { …
Ricardo_arg
  • 520
  • 11
  • 28
0
votes
2 answers

Why std::Hash equal for differen strings?

Why std::Hash has equal result for different strings? I used msvc2010sp1 and I was suprised when saw this result: int _tmain(int argc, _TCHAR* argv[]) { std::string sUniqId ("IndexBuf"); std::stringstream sStream; sStream << 10; …
angevad
  • 187
  • 1
  • 1
  • 14
0
votes
1 answer

Clang compiling error on 'std::hash'

I am trying to compile a project on my mac, which is originally written on linux. It went smoothly on archlinux but has a lot of errors on mac. Especially, I'm very confused with this error message: In file included from…
Nothing More
  • 873
  • 12
  • 29
0
votes
1 answer

My std::hash for std::tuples... Any improvements?

Some may have noticed that std::hash does not support tuples. So I added an overload which just seems "nicer" than the solution I saw up till now. Anyone got ideas to further cut down this code? Please note that this is a compiler killer! The only…
thesaint
  • 1,253
  • 1
  • 12
  • 22
0
votes
1 answer

What is the purpose of std::hash and/or boost::hash ?

Why providing an hash function without specifing any implementation of reference and also without specifying the algorithm of reference ( md5, sha256, etc etc ) ? Also there are similar features for data structures such as the C++ standard-compliant…
user1824407
  • 4,401
  • 4
  • 15
  • 20
-1
votes
1 answer

How to find multiplier x if x * c1 = c2, but x * c1 causes overflow

I am writing a code that will find collisions for std::hash and trying to reverse some of hash calculation steps. There is such a multiplication in std::hash implementation. size_t hash2 = shift_mix(hash1) * mul; I know hash2 - from…
1 2 3
4