Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:Hash(since C++11)

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      AHash is a function object for which the output depends only on the input and has a very low probability of yielding the same output given different input values.

      [edit]Requirements

      The typeT satisfiesHash if

      Given

      • h, a value of typeT orconst T, whose argument type isKey,
      • k, a value of type convertible toKey orconst Key,
      • u, anlvalue expression of typeKey.

      The following expressions must be valid and have their specified effects.

      ExpressionReturn typeRequirements
      h(k)std::size_tThe returned value depends only on the value ofk for the duration of the program.

      All evaluations ofh(k) executed within a given execution of a program yield the same result for the same value ofk.

      The probability ofh(a)== h(b) fora!= b should approach1.0/std::numeric_limits<std::size_t>::max().

      h(u)std::size_tu is not modified.

      [edit]Standard library

      (C++11)
      hash function object
      (class template)[edit]

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2291C++11same results for same arguments were required in all casesonly required within a single execution
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/Hash&oldid=156510"

      [8]ページ先頭

      ©2009-2025 Movatter.jp