다음을 통해 공유


hash 클래스

Computes hash code for a value.

template<class Ty>
    struct hash
        : public unary_function<Ty, size_t> {
    size_t operator()(Ty _Val) const;
    };

설명

The member function defines a hash function, suitable for mapping values of type Ty to a distribution of index values. The member operator returns a hash code for _Val, suitable for use with template classes unordered_map, unordered_multimap, unordered_set, and unordered_multiset. Ty may be any scalar type, string, wstring, error_code, error_condition, u16string, or u32string.

예제

 

// std_tr1__functional__hash.cpp 
// compile with: /EHsc 
#include <functional> 
#include <iostream> 
#include <unordered_set> 
 
int main() 
    { 
    std::unordered_set<int, std::hash<int> > c0; 
    c0.insert(3); 
    std::cout << *c0.find(3) << std::endl; 
 
    return (0); 
    } 
 
3

요구 사항

헤더: <기능>

네임스페이스: std

참고 항목

참조

<unordered_map>

unordered_multimap 클래스

unordered_multiset 클래스

<unordered_set>