stdhash Questions

3

Solved

I'm trying to use QString as the key in a std::unordered_map, however I get the error: error C2280: 'std::hash<_Kty>::hash(const std::hash<_Kty> &)': attempting to reference a deleted ...
Unblinking asked 30/1, 2018 at 16:24

1

Solved

I have some random test parameters for which I need to calculate a hash to detect if I ran with same parameters. I might run the test using the same source recompiled at a different time or run on ...

3

Solved

#include <iostream> int main() { std::hash<int> hash_f; std::cout << hash_f(0) << std::endl; std::cout << hash_f(1) << std::endl; std::cout << hash_f(...
Floeter asked 11/7, 2016 at 10:39

1

Solved

I thought it would have been, but I can't find this in my standard library implementation (gcc-4.8.2). Why is std::hash not already specialised for std::reference_wrapper? #pragma once #include &...
Nork asked 31/3, 2015 at 21:35

2

With a Regular Type, I mean the definition of Stepanov in Elements of Programming, basically, that there's the concept of equality and that objects which are copies of each other compare equal. So...
Eastward asked 30/4, 2015 at 13:40

1

Solved

I was trying to specialize hash for my own type, a templated key. I was basing it off cppreference. I get the compile error "The C++ Standard doesn't provide a hash for this type". I figure I jus...
Kuching asked 27/4, 2015 at 10:23

3

Can the C++11 std::hash type be used to hash function pointers? There is a hash partial specialization defined as template <typename T> struct hash<T*>; but since function pointers a...
Laze asked 1/11, 2013 at 2:54

4

Solved

Is the floating point specialisation of std::hash (say, for doubles or floats) reliable regarding almost-equality? That is, if two values (such as (1./std::sqrt(5.)/std::sqrt(5.)) and .2) should co...
Toluene asked 18/2, 2013 at 19:25

1

Solved

I have defined this template class structure: template<typename T> struct Outer { struct Inner { /* ...some stuff... */ }; }; I want to put Inner objects into an unordered_map (actually, ...
Wino asked 11/8, 2014 at 11:47

2

Solved

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<Outer::Inne...
Hertel asked 20/4, 2014 at 21:11

1

Solved

I have an abstract base class Hashable that classes that can be hashed derive from. I would now like to extend std::hash to all classes that derive from Hashable. The following code is supposed to...
Hydrogenate asked 20/2, 2014 at 7:10

2

Solved

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 thi...
Ticktack asked 20/1, 2011 at 17:34

2

Solved

Standard library implements std::hash as a template struct that is specialized for different types. It is used like this: #include <iostream> #include <functional> int main() { std::...
Photoreconnaissance asked 24/11, 2013 at 19:20

2

Solved

I can replace the actual implementation of std::hash with my own definition of std::hash in C++ 11 ? I mean from my codebase, without touching the standard library. I can't see any use for virtua...
Mercurial asked 6/8, 2013 at 11:29

1

Solved

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 somethin...
Martial asked 26/7, 2013 at 17:7

2

Solved

I'm guessing std::hash is defined as a template struct in order to avoid implicit type conversions done during overloaded function resolution. Is it a correct thing to say? I mean, I would prefer t...
Norry asked 7/7, 2013 at 21:34

3

Solved

Why doesn't the C++ standard specify that std::hash<T> is specialized for char*, const char*, unsigned char*, const unsigned char*, etc? I.e., it would hash the contents of the C string until...
Irv asked 16/4, 2013 at 18:34

1

Solved

So the library I use has an enum (say it's named LibEnum). I need to have an std::unordered_set of LibEnum, but I get compilation error that there is no specialized std::hash for it. I could easily...
Seedcase asked 11/2, 2013 at 14:23

3

Solved

If I did std::hash using libstdc++ and then did one on the upcoming C++11 VS 2012 library - would they match? I assume that hash implementations are not part of the C++ specification and can vary ...
Coxcombry asked 16/8, 2012 at 15:38

5

Solved

I know hashing infinite number of string into 32b int must generate collision, but I expect from hashing function some nice distribution. Isn't it weird that these 2 strings have the same hash? s...
Kite asked 1/11, 2011 at 15:19
1

© 2022 - 2024 — McMap. All rights reserved.