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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:16:05+00:00 2026-06-17T09:16:05+00:00

Is std::array movable? In Bjarne Native 2012 presentation slides (slide 41) it lists std::array

  • 0

Is std::array movable?

In Bjarne Native 2012 presentation slides (slide 41) it lists std::array as one of the only containers that isn’t movable.

A quick look on gcc 4.8 libraries source code seems to confirm that std::array is not movable:

std::vector:

/* @brief  %Vector move constructor.
   ...       */
  vector(vector&& __x) noexcept
  : _Base(std::move(__x)) { }

while in std::array the only method that receives a rvalue reference parameter is the random element access, which avoids a return by copy:

get(array<_Tp, _Nm>&& __arr) noexcept
    { /*...*/ return std::move(get<_Int>(__arr)); }

Is move-constructor and move-assignment for std::array defaulted created, or is std::array unmovable? If it is unmovable, why std::array cannot be moved while std::vector can?

  • 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-17T09:16:05+00:00Added an answer on June 17, 2026 at 9:16 am

    std::array is movable only if its contained objects are movable.

    std::array is quite different from the other containers because the container object contains the storage, not just pointers into the heap. Moving a std::vector only copies some pointers, and the contained objects are none the wiser.

    Yes, std::array uses the default move constructor and assignment operator. As an aggregate class, it’s not allowed to define any constructors.

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

Sidebar

Related Questions

What is the difference between std::array and std::vector ? When do you use one
I am trying to create a base class that is a wrapper around std::array
I have some C+ arrays that I have built as follows: std:array<const char *,
I have modified std.array.array so that it will always work at compile time, and
Is the data in std::array<std::array<T,N>, M> guaranteed to be contiguous? For example: #include <array>
How can I use std::shared_ptr for array of double? Additionally what are advantages/disadvantages of
I want to reverse a 2d array of type char using std::reverse() function in
What is the cheapest way to initialize a std::vector from a C-style array? Example:
I have problem i need to convert from my Array structure to std::vector<int> ...
I am trying to cvopy boost::array<char> to std::string . boost::array<char, 1024> _buffer; std::string data;

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.