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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:12:23+00:00 2026-06-18T12:12:23+00:00

I have an object something like the following and I’m trying to implement a

  • 0

I have an object something like the following and I’m trying to implement a move constructor for so you can have an insert for std::vector<Mesh>.

struct Mesh
{    
    std::vector<Vector3> vPoint;
    bool Valid;

    Mesh(Mesh&& other)
    {
        vPoint = std::move(other.vPoint);
        Valid = std::move(other.Valid);
    }
};

Is this the correct way?
And if so what is the value of other.Valid after std::move operates on it?

Edit:

Also if I have an instance of this object do I need to use std::move in the following scenario?

std::vector<Mesh> DoSomething()
{
    Mesh mesh; //Imagine vPoint is filled here to

    std::vector<Mesh> meshes;
    meshes.push_back(std::move(mesh)); // Here is my question, std::move? or just pass mesh here?

    return meshes;
}
  • 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-18T12:12:24+00:00Added an answer on June 18, 2026 at 12:12 pm

    You should write your move constructor as follows:

    Mesh( Mesh&& other )
    : vPoint( std::move( other.vPoint ) )
    , Valid( std::move( other.Valid ) )
    {}
    

    The disadvantage of assignment within the constructor body as opposed to using the constructor initializer list is that in the former case the member objects of the Mesh object that you’re moving to are default constructed and then assigned to within the body. In the latter case they’re constructed directly from the result of the std::move call.

    You shouldn’t read from an object, be it an integral type, or a more complex object, after moving it. Such objects exist in an unspecified state.

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

Sidebar

Related Questions

I'm trying to do something like the following in Script# jQuery.GetJson(./GetData/, delegate(object json) {
I have made something like the following code: protected void Page_Load(object sender, EventArgs e)
I have a json object that looks something like this: Array ( [algorithm] =>
I have to pass an object to an button's action... something like [myButton addTarget:self
I have a list of object that is the data source. Something like that:
I would like to do something like the following: class Foo(object): def __init__(self): self.member
I have a JavaScript object that looks something like this: var myTextOptions = {
So I have a helper method that looks something like the following: private D
I have an object that looks something like this: public class Student { public
So I have a program that runs something like the following public class SHandler

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.