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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:25:30+00:00 2026-06-19T02:25:30+00:00

Per a discussion from Is `std::vector<primitive>::clear()` a constant time operation? , it was noted

  • 0

Per a discussion from Is `std::vector<primitive>::clear()` a constant time operation?, it was noted that the C++ standard does not appear to specify the running time of vector::clear.

It specifies the running time of list::clear (linear; §23.3.5.4.5), .clear for both ordered (table 102) and unordered associative containers (table 103) (both linear). However, vector::clear appears to be missing (though other vector members, like .data and .swap appear to have specified complexity).

Is it really unspecified, or did I miss something?

  • 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-19T02:25:31+00:00Added an answer on June 19, 2026 at 2:25 am

    Is it really unspecified, or did I miss something?

    Yes. At the moment, it is really unspecified.

    There is an open library issue for this, whose text contains a link to a relevant Q&A on StackOverflow. The answer by Jonathan Wakely to that question clarifies what has been going on.

    According to the linked proposal, the complexity requirement of clear() should be made linear for all sequence containers. However, one must keep in mind that complexity requirements are just upper bounds. Per Paragraph 17.5.1.4/7 of the C++11 Standard:

    Complexity requirements specified in the library clauses are upper bounds, and implementations that provide better complexity guarantees satisfy the requirements.

    This allows for possible optimizations, but does not mandate them.

    Even when the linked proposal will be accepted, we will not be allowed to assume that clear() has O(1) complexity for sequence containers of non-class elements, even though this seems to be a natural and common optimization strategy (and the answer by dasblinkenlight to this question on SO confirms it).

    Implementations will be allowed to adopt this strategy (per 17.5.1.4/7), but they won’t be required to do so, because nowhere in the Standard such a constraint is (nor is it proposed to be) specified.

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

Sidebar

Related Questions

Per a client's request I have written a communication class that inherits from webclient.
UPDATE: I recently learned from this question that in the entire discussion below, I
I would like to start a community discussion. As per my question, when do
Per a great answer from another question I have begun mounting global resources (css/js/images)
Is it possible to return querysets that return only one object per foreign key?
So, per Mehrdad's answer to a related question , I get it that a
im looking to write a daemon that: reads a message from a queue (sqs,
per the discussion of R programming styles, I saw someone once said he puts
I know that, how to implement virtual function call resolution is not part of
I understand that there are several questions on OOD; this one is not a

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.