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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:45:13+00:00 2026-05-25T16:45:13+00:00

Do I read N3291 12.8.(11/15/28) Copying and moving class objects class.copy] correct that the

  • 0

Do I read N3291 “12.8.(11/15/28) Copying and moving class objects class.copy]” correct that the implicitly-declared move constructor

  • does an element-wise move of all non-static data-members (probably via respectively defined T(T&&)
  • and if any non-static data-member can not be moved, the implicit move-constructor will be marked as deleted and not tried to be copied as a “fallback”? (yes, move is defined for built-in types, but actually is a copy).

and likewise the move-assign, using the respective T operator=(T&&) of the elements.

Example:

struct CopyOnly {
    CopyOnly();
    CopyOnly(const CopyOnly&);
}; // declaring a copy means no implicit move.

struct Question {
    std::vector<int> data_;
    CopyOnly         copyOnly_;
};

The class Question

  • will have implicitly-declared copy-constructor and assign
  • will have implicitly-declared move-constructor and move-assign, but they will be =deleted, because the non-static data-member data_ is only copyable, but not movable?

Update. A side-question: For Question q; will std::move(q) still work? Will the fallback to copy happen there? Or will the implicitly-declared move-ctor force the compiler to stop with an error? Here it does compile.

Update 2. What does the compiler generate for the non-movable data-members if I declare the move-ctor Question(Question&&) =default? Does it then fallback to copying those?

  • 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-25T16:45:14+00:00Added an answer on May 25, 2026 at 4:45 pm

    You read it incorrectly. This would break lots of C++03 classes in cases such as the following

    Question getQuestion();
    Question q(getQuestion()); // use of deleted move constructor!
    

    Instead, the FDIS says that a move constructor will be declared iff {there is no user declared {copy constructor, {copy, move} assignment operator, destructor} and the implicitly declared move constructor would not be defined as deleted}.

    Regarding Update 2. It has been brought to my attention that if you explicitly-default the move constructor, it will be defined as deleted by the condition

    for the move constructor, a non-static data member or direct or virtual base class with a type that does not have a move constructor and is not trivially copyable.

    In the following, the move constructor will be defined as deleted, because CopyOnly is not trivially copyable.

     struct Question 
     {
            std::vector<int> data_;
            CopyOnly         copyOnly_;
    
            Question(Question&&) = default;
     };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read this question's answers that explain the order of the LINQ to objects
I read somewhere once that the modulus operator is inefficient on small embedded devices
I read in this article that a company has created a software capable of
I read somewhere that md5 is not 100% secure. Hence, the question.
Read about Fog: http://fog.io Does Python have anything like it? (a library for cloud
Read that the following code is an example of unsafe construction as it allows
I read a long time ago about a rule that using an object we
Read this question about how to compare custom objects in C++. I did not
I read about __packed__ from here and, I understood that when __packed__ is used
I read how this can be made to work using forward declarations. class 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.