Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7546351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:10:35+00:00 2026-05-30T09:10:35+00:00

In STL containers, like map and set – How the unique key is determined

  • 0

In STL containers, like map and set – How the unique key is determined for user-defined types?

In C#, this is done by overriding GetHashCode and Equals methods.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:10:36+00:00Added an answer on May 30, 2026 at 9:10 am

    A map, for example, takes 4 parameters as its template arguments. Most of the time, developers use just 2 of them i.e. the Key type and the Value type. But, one can also provide a functor that compares objects of the Key type (whatever type it would be).

    From cplusplus.com:

    Compare: Comparison class: A class that takes two arguments of the key type and returns a bool. The expression comp(a,b), where comp is
    an object of this comparison class and a and b are key values, shall
    return true if a is to be placed at an earlier position than b in a
    strict weak ordering operation. This can either be a class
    implementing a function call operator or a pointer to a function (see
    constructor for an example). This defaults to less, which returns
    the same as applying the less-than operator (a

    http://www.cplusplus.com/reference/stl/map/

    It is true for almost all cases (when using for sorting, or for any other container) and this principle holds across quite a few languages and platforms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for the optimal strategy to use STL containers (like std::map and
I have two containers, let's say they're defined like this: std::vector<std::unique_ptr<int>> a; std::vector<std::unique_ptr<int>> b;
I know STL containers like vector copies the object when it is added. push_back
If you use stl containers together with reference_wrappers of POD types, code such as
I've always been a bit confused about how STL containers (vector, list, map...) store
I'd like use boost::unordered_map<key,value> , where key is a std::set<int> . Since a set
What are containers/adapters? I have basic knowledge of C++ and its sub-topics like (class/templates/STL).
Can any of STL algorithms/container operations like std::fill , std::transform be executed in parallel
Is it possible to create an STL-like container, or even just an STL-style iterator,
How does container object like vector in stl get destroyed even though they are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.