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

  • Home
  • SEARCH
  • 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 9020163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:56:54+00:00 2026-06-16T04:56:54+00:00

When I am reading some article i found this line is so cryptic. new

  • 0

When I am reading some article i found this line is so cryptic.

new (new_ptr + i) T(std::move(old_ptr[i]));

Can somebody explains how this syntax works?

  • 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-16T04:56:56+00:00Added an answer on June 16, 2026 at 4:56 am

    Its a placement.

    new (new_ptr + i) T(std::move(old_ptr[i]));
    

    Here we can simplify this to:

    new (<destinationLocation>) T(<constructor parameters);
    

    This is normall C++03 and basically allows you to create an object dynamically in an area of memory that you have pre-allocated (its an advanced technique that most people will not use (unless they are building their own container like objects)).

    The std::move() part is from C++11 and is creating a special reference type that allowes the move constructor to be used in the type T.

    new T(std::move(<source Obj>));
    

    This basically says create a new T using the source object and use the move constructor for effeciency. This means the ‘source Obj’ will be left in an undefined state (thus not usable) after the move but it allows from efficient object creation.

    Combining the two you get placement new with move construction using an element from an array as the source object.

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

Sidebar

Related Questions

I am reading about HHT caching, found a website article here which explains some
I was just reading this article and it mentions that some organization had an
New to emberjs, after reading some article, I am confused with emberjs dom handle
From my reading of some android forensic articles i understand that sqlite records can
When reading some FreeBSD source code (See: radix.h lines 158-173), I found variable declarations
After reading some material on this subject I'm still not sure what the difference
I was reading some sort of article stating you need Mac OS X to
I installed memcached by reading this article on Windows7 but unfortunately i keep getting
I found an interesting question about retransmission queue on TCP, I've been reading this
I was reading this article about Double-Checked locking and out of the main topic

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.