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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:35:59+00:00 2026-05-14T14:35:59+00:00

I recently installed Visual Studio 2010 Professional RC to try it out and test

  • 0

I recently installed Visual Studio 2010 Professional RC to try it out and test the few C++0x features that are implemented in VC++ 2010.

I instantiated a std::vector of std::unique_ptr, without any problems. However, when I try to populate it by passing temporaries to push_back, the compiler complains that the copy constructor of unique_ptr is private. I tried inserting an lvalue by moving it, and it works just fine.

#include <utility>
#include <vector>

int main()
{
    typedef std::unique_ptr<int> int_ptr;

    int_ptr pi(new int(1));

    std::vector<int_ptr> vec;

    vec.push_back(std::move(pi));      // OK
    vec.push_back(int_ptr(new int(2))); // compiler error
}

As it turns out, the problem is neither unique_ptr nor vector::push_back but the way VC++ resolves overloads when dealing with rvalues, as demonstrated by the following code:

struct MoveOnly
{
    MoveOnly() {}
    MoveOnly(MoveOnly && other) {}

private:

    MoveOnly(const MoveOnly & other);
};

void acceptRValue(MoveOnly && mo) {}

int main()
{
    acceptRValue(MoveOnly()); // Compiler error
}

The compiler complains that the copy constructor is not accessible. If I make it public, the program compiles (even though the copy constructor is not defined).

Did I misunderstand something about rvalue references, or is it a (possibly known) bug in VC++ 2010 implementation of this feature?

  • 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-14T14:35:59+00:00Added an answer on May 14, 2026 at 2:35 pm

    Unfortunately, /Za is buggy. It performs an elided-copy-constructor-accessibility check when it shouldn’t (binding rvalue references doesn’t invoke copy constructors, even theoretically). As a result, /Za should not be used.

    Stephan T. Lavavej, Visual C++ Libraries Developer (stl@microsoft.com)

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

Sidebar

Related Questions

I recently installed Visual Studio 2010 for my c++ course at school. Im very
I've been upgrading some Silverlight 3 apps to Silverlight 4 in Visual Studio 2010.
I've recently installed VS 2010 Ultimate, and decided to move a project to TeamCity,
I recently installed Windows 2008 Server to replace a crashed hard drive on a
I recently installed MySQL 5 on Windows 2003 and tried configuring an instance. Everything
I recently installed the Eclipse Metrics Plugin and have exported the data for one
We recently installed Team Foundation Server 2008 and we are using it for both
I recently installed VS 6.0 after installing VS 2008 and overwrite JIT settings ..
I have recently installed .net 3.5 SP1. When I deployed a compiled web site
I've recently installed VS2008. The project I'm working on uses vstest and 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.