After reading the discussion on operator< for std::weak_ptr, I can't see any reason why defining std::hash to use the control block for std::weak_ptr wouldn't work. I also can't believe that this was ignored by the standards committee. Has anybody…
I have defined this template class structure:
template struct Outer {
struct Inner { /* ...some stuff... */ };
};
I want to put Inner objects into an unordered_map (actually, not directly them but containers of them, so the approach…
I have a template class Baz which contains a nested class Sub. I'd like to define a hash function for this subclass by specializing std::hash. However, it doesn't seem to work.
#include
struct Foo {
struct Sub {
};
};
template…
I have a class (call it Outer) which has a private member class (Inner). I want to store instances of Outer::Inner in unordered standard containers, so I want to specialize std::hash.
However, when writing this:
namespace std {
…
I'm trying to hold a polymorphic type as a key in a map.
I came up with the following two structures:
Note that Game is an abstract class and the data structure I use is :
std::unordered_map _allGames;
while gamePtr is a typedef…
I'm using C++11 and the std::hash algorithm.
I was wondering, what actual hash implementation is used?
I would assume MD5 or SHA, but I can't dig any info from the internets.
Also, I'd like to know the actual returned bit-width of the hash, as I…
I'm using the unordered_map of TR1 implementation in my code and the linker gives weird errors I cannot even decipher:
BPCFG.o: In function `std::__detail::_Hash_code_base,…
I need to use QList as a key to std::unordered_map. The purpose of this is to optimize searching over a table of data by making index over the unique key columns.
So I made this code. It's not complete, but lists some basic data types that…
The following code implements a hash function for a std::tuple which is then used in a different segment of my code-base in a std::unordered_map of std::tuples.
// compute hash function recursively through each std::tuple element
template
Discussion:
Let's say I have a struct/class with an arbitrary number of attributes that I want to use as key to a std::unordered_map e.g.,:
struct Foo {
int i;
double d;
char c;
bool b;
};
I know that I have to define a…
I was using an ordered set declared as so:
std::set > myset;
After doing some analysis of the way I was using the set, I concluded that an unordered_set would be a smarter choice. But when I changed…
I'm currently working on getting a C++ application to compile in both Windows and Linux, during some debugging I've found that
std::this_thread::get_id().hash()
doesn't compile on Linux with gcc 4.8 (thanks to the comments in this thread). The…
Hi I have a question on std::hash if I have 2 large strings for comparison and I am willing to accept that std::hash will compare equal in most cases is it more performance compliant to do something like the following instead of a direct string…
Is there an easy way to do the following with C++11 & Boost:
use the standard definitions of std::hash whenever available from
use boost::hash_value to define std::hash in those cases where std::hash is missing but boost::hash_value is…
I am using the std::hash in cpp utility to generate the hash for the string. My requirement is to generate the fixed size hash of 11 digits. The hash function need not be great to never have collision.
The only requirement that I have is to generate…