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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:09:33+00:00 2026-06-15T04:09:33+00:00

In Exceptional C++, Herb Sutter wrote about auto_ptr : The problem is that auto_ptr

  • 0

In Exceptional C++, Herb Sutter wrote about auto_ptr:

The problem is that auto_ptr does not quite meet the requirements of a
type you can put into containers, because copies of auto_ptrs are not
equivalent.

The book was written with respect to C++03, and I wonder whether this is still valid as this code seems to compile perfectly under GCC 4.7.1:

#include <vector>

struct Foo
{
    Foo() { }
    Foo( Foo&& ) { }
    Foo( Foo& ) = delete;
    Foo& operator= (Foo&&) { return *this; }
    Foo& operator= (Foo&) = delete;
};

int main()
{
    std::vector<Foo> bar;
    bar.push_back(Foo());
}

But accepting moveable-but-not-copyable objects could also be a GCC extension. I am not sure. What are the requirements for std::vector objects?

  • 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-15T04:09:34+00:00Added an answer on June 15, 2026 at 4:09 am

    To be able to use std::vector<Foo>::push_back(), the type Foo needs to be MoveInsertable or CopyInsertable (23.2.1 [container.requirements.general] paragraph 13) according to 23.2.3 [sequence.rqmts] paragraph 16 (Table 101). Clearly, providing the MoveInsertable model requires that you use push_back() with an r-value, possibly obtained using std::move(x). That is, you don’t even need the move assignment operator to be able to use std::vector<...>::push_back(). I think not all standard libraries correctly take this latter part into account and delegate to insert(): delegating to insert() doesn’t work according to the C++ 2011 standard because insert() also requires the type to be MoveAssignable or CopyAssignable.

    Trying to search for push_back unfortunately fails to point to Table 101 for me because the name is split into push_ and back() by a line break…

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

Sidebar

Related Questions

I am reading the book "Exceptional C++" by Herb Sutter, and in that book
I have been reading Exceptional C++ by Herb Sutter . On reaching Item 32
A long time ago I read an article (probably) by Herb Sutter that introduced
I'm currently doing a lot of things on exception safety. (Herb Sutter's Exceptional C++,
In Herb Sutter's book Exceptional C++ (1999) , he has words in item 10's
I've read man 2 kqueue but have not found out how I can get
I read that on Unix systems, malloc can return a non-NULL pointer even if
I'm looking for websites that showcase screenshots of applications with exceptional UI design. I'm
It's my understanding that common wisdom says to only use exceptions for truly exceptional
It is said that Blitz++ provides near-Fortran performance . Does Fortran actually tend to

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.