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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:26:30+00:00 2026-06-14T05:26:30+00:00

Consider the following class: class A { public: std::string field_a; std::string field_b; } Now

  • 0

Consider the following class:

class A
{
public:
   std::string field_a;
   std::string field_b;
}

Now consider the following copy construction:

A a1(a2);

The copy construction will adequately copy A despite the lack of of an explicit copy constructor because the copy constructors for std::string will be called by the compiler generated implicit copy constructor.

What I wish to know is, is the same true for move construction?

EDIT: Testing here shows that:

A a2(std::move(a1));

Will actually result in a copy construction, unless the specific move constructor:

A( A && other ) : a(std::move(other.a)) {}

Is defined.

EDIT EDIT
I pinged Stephan T Lavavej and asked him why VC 2012 doesn’t seem to follow what draft 12.8 states regarding implicit move constructor generation. He was kind enough to explain:

It’s more of a “feature not yet implemented” than a bug. VC currently
implements what I refer to as rvalue references v2.0, where move
ctors/assigns are never implicitly generated and never affect the
implicit generation of copy ctors/assigns. C++11 specifies rvalue
references v3.0, which are the rules you’re looking at.

  • 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-14T05:26:32+00:00Added an answer on June 14, 2026 at 5:26 am

    Yes, from the C++11 draft, 12.8:

    If the definition of a class X does not explicitly declare a move constructor, one will be implicitly declared
    as defaulted if and only if

    • X does not have a user-declared copy constructor,
    • X does not have a user-declared copy assignment operator,
    • X does not have a user-declared move assignment operator,
    • X does not have a user-declared destructor, and
    • the move constructor would not be implicitly defined as deleted.

    The last condition is specified with more detail later:

    An implicitly-declared copy/move constructor is an inline public member of its class. A defaulted copy/move constructor for a class X is defined as deleted (8.4.3) if X has:

    • a variant member with a non-trivial corresponding constructor and X is a union-like class,
    • a non-static data member of class type M (or array thereof) that cannot be copied/moved because
      overload resolution (13.3), as applied to M’s corresponding constructor, results in an ambiguity or a
      function that is deleted or inaccessible from the defaulted constructor,
    • a direct or virtual base class B that cannot be copied/moved because overload resolution (13.3), as
      applied to B’s corresponding constructor, results in an ambiguity or a function that is deleted or
      inaccessible from the defaulted constructor,
    • any direct or virtual base class or non-static data member of a type with a destructor that is deleted
      or inaccessible from the defaulted constructor,
    • for the copy constructor, a non-static data member of rvalue reference type, or
    • 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.

    Plainly speaking, the move constructor will be implicitly declared if:

    1. The class does not have user-declared any of the other special member functions.
    2. The move constructor can be sensibly implemented by moving all its members and bases.

    Your class obviously complies with these conditions.

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

Sidebar

Related Questions

Consider the following code : class TextMessage{ public : TextMessage(){}; TextMessage(std::string _text):text(_text){} std::string text;
Consider the following class hierarchy: public class Foo { public string Name { get;
Consider the following code: public class MyClass { public static string MyStaticMethod() { //string
Consider the following sample code: #include <iostream> using namespace std; class base { public:
Consider the following program #include <iostream> #include<cstdlib> using namespace std; class E { public:
Consider the following code: #include<iostream> #include<vector> using namespace std; class Foo { public: template<
Consider the following minimal example. #include <vector> class Data { std::vector<int>& v; public: Data(std::vector<int>&
Consider the following example: class MyContainer { std::vector<void *> v; public: void Put(void *x)
Consider the following example : class MyClass { // Getters by copy ? public:
Consider the following code: #include <iostream> using namespace std; class B{ public: B(){} };

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.