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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:40:03+00:00 2026-05-18T02:40:03+00:00

Which is the right way to call base class move ctor? this (works in

  • 0

Which is the right way to call base class move ctor?

this (works in MSVC2010, but not in CBuilder2010):

struct Foo
{
    Foo(Foo&& other) { }
};

struct Bar : public Foo
{
    Bar(Bar&& other) : Foo((Foo&&)other) { }
};

or (works in CBuilder2010, but not in MSVC2010):

struct Foo
{
    Foo(Foo&& other) { }
};

struct Bar : public Foo
{
    Bar(Bar&& other) : Foo(&other) { }
};

or, are they both wrong? If so, what’s the right way (in terms of what’s specified in the C++0x standards)?

Note: I can’t figure out how to get it to work in CBuilderXE (both versions don’t work).

  • 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-18T02:40:03+00:00Added an answer on May 18, 2026 at 2:40 am

    The first option looks logical although I would spell it std::forward<Bar>(other).

    I have no idea what causes CBuilder to think that the type of &other is Bar&& and not Bar*.

    Basically what’s happening here is that once an rvalue reference is named it is no longer an rvalue reference, that’s what std::forward is for, it maintains the rvaluness (to coin a phrase), so when you call : Foo(other) you’re calling the copy constructor rather than the move constructor.

    This should be the idiomatic (and standard compliant) way to achieve what you’re trying to do (unless I’m badly misunderstanding the FCD).

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

Sidebar

Related Questions

I have this code which compiles and works as expected: class Right {}; class
Alright, so I have a base class which we'll call TFruit . From this
Right now I have this SQL query which is valid but always times out:
Right now I have a base class for my pages which inherits System.Web.UI.Page and
Not even sure if this is the right way to title the question. I
Hey guys I'm not sure if I'm going about all this the right way.
I have this design which I cannot seem to get right, I would like
may be its too simple but I couldnt find the right way. In C++
I have a base abstract class with several classes which extend and override it,
We have a script right now which our Windows users run on a Linux

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.