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 7756083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:43:42+00:00 2026-06-01T12:43:42+00:00

I searched for an implementation of std::map runtime ordering and have found this solution:

  • 0

I searched for an implementation of std::map runtime ordering and have found this solution:
STL std::map dynamic ordering

It is clear for me, but I don’t understand, how it can be possible to use OrderingType in the constructor of std::map. std::map has a constructor, which gets a comparator object as an argument. So it is normal from my point of view to use code like this:

int main()
{
   Ordering<int> test_ordering( ASCENDING );   
   CUSTOMMAP map1( test_ordering );

   return 0;
}

But code from above mentioned topic also compiles:

int main()
{
   CUSTOMMAP map1( ASCENDING );
   //...
   return 0;
}

I don’t understand, why it works: constructor of std::map must not get argument of OrderingType enumeration instead of Ordering class object itself.

  • 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-06-01T12:43:43+00:00Added an answer on June 1, 2026 at 12:43 pm

    If the constructor on Ordering<int> that takes your enumeration isn’t declared as explicit, then it is considered a “conversion constructor” that can automatically be inserted when the compiler has a need to convert from your enumeration type to the Ordering<int> type. So the compiler is effectively taking this:

    CUSTOMMAP map1( ASCENDING );
    

    and transforming it into this:

    CUSTOMMAP map1( Ordering<int>(ASCENDING) );
    

    This is called an implicit conversion.

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

Sidebar

Related Questions

I searched SO for a fix for this, found it, but my implementation seems
I have searched but i didn't found any solution to my problem. I want
I have searched on this problem, but have found nothing. I have triple checked
Searched a lot about this problem but never found a answer, that solved it.
I searched for this and found Maudite's question about text editors but they were
I searched and found this question but did not like the answer. Is there
I've searched over this topic but found very few details which were helpful. With
I have searched everywhere and I cannot find this implementation anywhere. Let's say I
I know this question must have been covered endless of times, but I've searched
I searched google but couldn't find an answer to this rather simple question. I

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.