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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:29:02+00:00 2026-06-13T20:29:02+00:00

I use VS11 and use following: class ContextWrapper { public: ContextWrapper() { } //it

  • 0

I use VS11 and use following:

class ContextWrapper
{
public:

    ContextWrapper()
    {
    } //it should be defaulted I *guess* in order to have automatic move constructor ?
      // no support in VS11 for that now  

    Context* GetContext()
    {
        return this->context.get();
    }

    void SetContext(std::unique_ptr<Context> context)
    {
        this->context = std::move(context);
    }

    //ContextWrapper(ContextWrapper&& other):  context(std::move(other.context))
    //{
    //} // I would like this to be generated by the compiler

private:
    ContextWrapper(const ContextWrapper&);
    ContextWrapper& operator= (const ContextWrapper&);

    std::unique_ptr<Context> context;
};

I would like this class to have generated move constructor/assignment. Is the fact that I don’t have a trivial constructor the reason I don’t get move ? Or there are other factors that influence this ?

  • 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-13T20:29:03+00:00Added an answer on June 13, 2026 at 8:29 pm

    This part of C++11 is unfortunately in flux. And whatever the standard is going to say, VC11 couldn’t possibly implement it yet. So for today, I don’t believe you’ll be able to count on generated move members.

    However, this is a good question and I wanted to get a good answer out on it.

    In general, the compiler should generate move members if you have no user-declared copy members nor destructor. = default and = delete counts as user-declared. If you declare one move member (e.g. move constructor), the other will not be implicitly generated.

    Unfortunately C++11 goes on to say that sometimes the move members are implicitly deleted when declared with =default, and sometimes their generation depends upon whether the bases and members have move members or are trivially copyable. This is all way too complicated and sometimes gives surprising behavior. Here is the CWG issue tracking this bug:

    http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1402

    As I write this, the issue does not have the correct proposed resolution. I expect that to change in about a week. At the 2012 Fall C++ standards meeting in Portland, OR, an agreement was reached which basically says:

    1. The compiler will never implicitly delete move members.
    2. The implicit generation of the move members will always be the same thing as = default.
    3. Implicit generation will not depend upon the triviality of the bases or members, nor whether or not they may throw when moved.

    In a nutshell, I expect the corrected wording of CWG 1402 to simply say:

    In general, the compiler should generate move members if you have no
    user-declared copy members nor destructor. = default and = delete
    counts as user-declared. If you declare one move member (e.g. move
    constructor), the other will not be implicitly generated.
    And if you =default a move member, you’ll get something that moves
    each base and member.

    (in proper standardize). I have not yet seen the wording that will say this. Jason Merrill is writing it up for us.

    This will mean that sometimes the compiler will implicitly generate throwing move members. But we were going for simple rules that nevertheless did the right thing most of the time (few surprises).

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

Sidebar

Related Questions

Use Elixir and have two entities -- Voter and Candidate -- with many to
use javascript or other method ? have any recommendation?
Use case: You have 2-3 files displayed in your MacVim window(s). You press ctrl+Q
Use scenario is pretty simple: I have a desktop only application that could be
Use Memcache php class to interact with the memcached. At the beginning all works
If I am reading this correctly, I should be able to use VS2010 solutions/projects
Use Case: Admin should be able to create user, and it should not attempt
Use case: we have some project meta-data files which we want tracked, but are
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
use ruby 1.9.2 rails 3.1.3 rake 0.8.7 and when rake cucumber start i have

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.