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

  • Home
  • SEARCH
  • 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 8966433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:01:23+00:00 2026-06-15T17:01:23+00:00

Possible Duplicate: Why does stack<const string> not compile in g++? We know that vector<const

  • 0

Possible Duplicate:
Why does stack<const string> not compile in g++?

We know that vector<const int> is not allowed.

But is map<const int, int>, map<int, const int>, or map<const int, const int> allowed?

Why (not)?

  • 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-15T17:01:24+00:00Added an answer on June 15, 2026 at 5:01 pm

    Items in a vector must be copy-constructible or (as of C++11) move-constructible.

    The key in a map only needs to be destructible, not copy/move constructible, so the requirements are much looser in this respect.

    As to why that is, it’s pretty simple: when/if a vector gets resized, the data from the existing buffer must be copied or moved into the new buffer. By contrast, a map normally stores its contents as nodes in a tree. Once a node is created, it will simply exist until it is destroyed. While the tree does need balancing at times, that only requires manipulating pointers between the nodes — the key in the node is never modified after the node is created.

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

Sidebar

Related Questions

Possible Duplicate: Why does stack<const string> not compile in g++? An answer to another
Possible Duplicate: Does not contain a constructor that takes 0 arguments I have a
Possible Duplicate: C++ STL stack question: Why does pop() not throw an exception if
Possible Duplicate: What does ^ in objective C mean? [SKSite requestSiteWithNameLike:@Stack Overflow completionHandler:^(SKSite *site,
Possible Duplicate: Does anyone know of a good C# API for Subversion? I'm designing
Possible Duplicate: What does “(void) new” mean in C++? I'm not familiar with C++
Possible Duplicate: Does a huge amount of warnings make C# compile time longer? In
Possible Duplicate: Does a finally block always run? I learned that the finally clause
Possible Duplicate: Does reading from stdin flush stdout? C++ Standard guarantees that all data
Possible Duplicate: does c++ standard prohibit the void main() prototype? Why is C++ not

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.