non-const find() in std::unordered_set

vladon

Why for there is non-const find() in std::unordered_set()?

iterator find( const Key& key );
const_iterator find( const Key& key ) const;

iterator is the same as const_iterator, why there is non-const version of find()?

http://en.cppreference.com/w/cpp/container/unordered_set/find

Slava

iterator is the same as const_iterator, why there is non-const version of find()?

Because iterator is not mandatory the same as const_iterator, as stated in documentation:

The member types iterator and const_iterator may be aliases to the same type. Since iterator is convertible to const_iterator, const_iterator should be used in function parameter lists to avoid violations of the One Definition Rule.

emphasis is mine. Since they are not mandatory the same some generic code can depend on particular type of iterator returned by find() and it should be consistent with other containers.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

std :: unordered_setのnon-constfind()

分類Dev

const char *にキャストされたstd :: stringがstd :: unordered_set <const char *>に見つかりません

分類Dev

std :: unordered_set :: findとstd :: findの奇妙なパフォーマンスの違い

分類Dev

Inserting multiple not-a-numbers into a std::unordered_set<double>

分類Dev

Undefined behavior in std::unordered_set with custom predicate

分類Dev

std :: string_viewおよびstd :: stringのstd :: unordered_set

分類Dev

std :: unordered_set <char>からの効果的な構築std :: string

分類Dev

std :: unordered_set :: findの結果をチェックするコードはコンパイルされません

分類Dev

std :: unordered_set ::複雑さを消去する

分類Dev

std :: unordered_set ::複雑さを消去する

分類Dev

boost :: range :: adapters :: transformed over std :: unordered_setの使用方法は?

分類Dev

std :: unordered_set :: equal_rangeイテレータの質問

分類Dev

`std :: unordered_set`の使用法を理解する

分類Dev

std :: unordered_set参照による戻りタイプと値

分類Dev

std :: setまたはstd :: unordered_setでの挿入順序の保持

分類Dev

std :: setの代わりにstd :: unordered_setを使用する場合

分類Dev

unordered_set :: findの複雑さは予測可能ですか?

分類Dev

std :: set <Type *> :: findを呼び出すときにconst_castを回避する

分類Dev

C ++:unordered_set :: findがfindよりも速いのはなぜですか?

分類Dev

エラー:「unordered_set」は「std」のメンバーではありません

分類Dev

std :: unordered_setイテレータトラバーサルの複雑さ

分類Dev

std :: unordered_set :: load_factor、なぜdoubleではなくfloatなのですか?

分類Dev

std :: unordered_setをどのようにstatic_castしますか?

分類Dev

std :: unordered_setをどのようにstatic_castしますか?

分類Dev

カスタム述語を使用したstd :: unordered_setの未定義の動作

分類Dev

std :: unordered_set operator ==()N ^ 2の複雑さはなぜですか?

分類Dev

std :: setおよびstd :: unordered_setは、emplace()を使用して要素をどのように構成しますか?

分類Dev

Unordered_map find const wchar_t *

分類Dev

std :: unordered_setのコンテンツをstd :: vectorに効率的に移動する

Related 関連記事

  1. 1

    std :: unordered_setのnon-constfind()

  2. 2

    const char *にキャストされたstd :: stringがstd :: unordered_set <const char *>に見つかりません

  3. 3

    std :: unordered_set :: findとstd :: findの奇妙なパフォーマンスの違い

  4. 4

    Inserting multiple not-a-numbers into a std::unordered_set<double>

  5. 5

    Undefined behavior in std::unordered_set with custom predicate

  6. 6

    std :: string_viewおよびstd :: stringのstd :: unordered_set

  7. 7

    std :: unordered_set <char>からの効果的な構築std :: string

  8. 8

    std :: unordered_set :: findの結果をチェックするコードはコンパイルされません

  9. 9

    std :: unordered_set ::複雑さを消去する

  10. 10

    std :: unordered_set ::複雑さを消去する

  11. 11

    boost :: range :: adapters :: transformed over std :: unordered_setの使用方法は?

  12. 12

    std :: unordered_set :: equal_rangeイテレータの質問

  13. 13

    `std :: unordered_set`の使用法を理解する

  14. 14

    std :: unordered_set参照による戻りタイプと値

  15. 15

    std :: setまたはstd :: unordered_setでの挿入順序の保持

  16. 16

    std :: setの代わりにstd :: unordered_setを使用する場合

  17. 17

    unordered_set :: findの複雑さは予測可能ですか?

  18. 18

    std :: set <Type *> :: findを呼び出すときにconst_castを回避する

  19. 19

    C ++:unordered_set :: findがfindよりも速いのはなぜですか?

  20. 20

    エラー:「unordered_set」は「std」のメンバーではありません

  21. 21

    std :: unordered_setイテレータトラバーサルの複雑さ

  22. 22

    std :: unordered_set :: load_factor、なぜdoubleではなくfloatなのですか?

  23. 23

    std :: unordered_setをどのようにstatic_castしますか?

  24. 24

    std :: unordered_setをどのようにstatic_castしますか?

  25. 25

    カスタム述語を使用したstd :: unordered_setの未定義の動作

  26. 26

    std :: unordered_set operator ==()N ^ 2の複雑さはなぜですか?

  27. 27

    std :: setおよびstd :: unordered_setは、emplace()を使用して要素をどのように構成しますか?

  28. 28

    Unordered_map find const wchar_t *

  29. 29

    std :: unordered_setのコンテンツをstd :: vectorに効率的に移動する

ホットタグ

アーカイブ