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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:30:58+00:00 2026-05-27T11:30:58+00:00

For standard copy constructors and assignment operators, I always think about implementing them or

  • 0

For standard copy constructors and assignment operators, I always think about implementing them or deleteing the defaults out of existence, if my class implements a destructor.

For the new move constructor and move operator, what is the right way to think about whether or not an implementation is necessary?

As a first pass of transitioning a system from pre-C++0x, could I just delete the default move constructor and move operator or should I leave them alone?

  • 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-27T11:30:59+00:00Added an answer on May 27, 2026 at 11:30 am

    You don’t have to worry about it, in the sense that when you user-declare a destructor (or anything else listed in 12.8/9), that blocks the default move constructor from being generated. So there’s not the same risk as there is with copies, that the default is wrong.

    So, as the first pass leave them alone. There may be places in your existing code where C++11 move semantics allow a move, whereas C++03 dictates a copy. Your class will continue to be copied, and if that caused no performance problems in C++03 then I can’t immediately think of any reason why it would in C++11. If it did cause performance problems in C++03, then you have an opportunity to fix a bug in your code that you never got around to before, but that’s an opportunity, not an obligation 😉

    If you later implement move construction and assignment, they will be moved, and in particular you’ll want to do this if you think that C++11 clients of your class are less likely to use “swaptimization” to avoid copies, more likely to pass your type by value, etc, than C++03 clients were.

    When writing new classes in C++11, you need to consider and implement move under the same criteria that you considered and implemented swap in C++03. A class that can be copied implements the C++11 concept of “movable”, (much as a class that can be copied in C++03 can be swapped via the default implementation in std), because “movable” doesn’t say what state the source is left in – in particular it’s permitted to be unchanged. So a copy is valid as a move, it’s just not necessarily an efficient one, and for many classes you’ll find that unlike a “good” move or swap, a copy can throw.

    You might find that you have to implement move for your classes in cases where you have a destructor (hence no default move constructor), and you also have a data member which is movable but not copyable (hence no default copy constructor either). That’s when move becomes important semantically as well as for performance.

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

Sidebar

Related Questions

If a have a class with both standard and copy constructors class Ex{ //constructor
A recent question got me wondering about explicit copy constructors. Here is a sample
I have a question regarding the C++ Standard. Suppose you have a base class
I'd like to use the following idiom, that I think is non-standard. I have
The MFC's root object CObject's copy constructor and assignment are disabled by default. In
When using the std::map with types that use trivial, non-throwing, copy constructors, a compiler
I've been thinking about storing C++ lambda's lately. The standard advice you see on
In the C++11 standard, Section 23.3.6.2 [vector.cons], the following is said: template <class InputIterator>
Given that: 1) The C++03 standard does not address the existence of threads in
If I write T t = T(); T is a class. I think this

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.