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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:44:44+00:00 2026-05-26T11:44:44+00:00

boost::array (or the tr1 or std version) offer some nice additional features over a

  • 0

boost::array (or the tr1or std version) offer some nice additional features over a built-in array.

Up to now, our codebase only contains built-in arrays, for example (made up, but the style matches):

WORD m_lastReadFlags[FLAGS_MAX];
...
WORD flagBuffer[FLAGS_MAX];
if (getFlags(flagBuffer)) {
  memcpy(m_lastReadFlags, flagBuffer, sizeof(m_lastReadFlags));
  ...

I think one’ll get the idea.

Now, my question is, for those places in the code, where dropping in boost::array would make sense (because of other changes made), is array a 100% semantics preserving drop-in for the built in array? (Possible compiler errors are OK — only silent behavioral changes are what’s bothering me.)

That is, could above code be re-written (for example) to use:

boost::array<WORD, FLAGS_MAX> m_lastReadFlags;

and the memcpy (possibly adapted to use c_array()or data()) and other array-like access would remain the same? Yes, of course I could also replace the local buffer by an array and remove the memcpy or use std::copy or something like that, but the point of this question is about the compatibility of built-in arrays and the array class.


Update: One thing that’s bothering me specifically is the places (like in the memcpy case) where the built-in arrays are used as pointers. Will all occurences be caught by the
compiler / handled correctly?

What about assignment?

T arr1[N]; // or array<T, N>
T arr2[N]; // or array<T, N>
T* p1;
...
// Note, not all combinations will compile:
arr1 = arr2;
p1 = arr1;
arr2 = p1;
...
  • 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-26T11:44:44+00:00Added an answer on May 26, 2026 at 11:44 am

    Yes, that should be fine, since the array class is precisely a wrapper for an automatic array. It has the same access syntax with square brackets, and if you need to get at the pointer, you know how to do it. You can even use std::copy everywhere and use iterators; chances are that that will be implemented by memcpy anyway.

    The array class is of aggregate type (no non-trivial constructors/destructor/assignment), so you can initialize it with the traditional aggregate (brace) initializer, just like a plain array.

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

Sidebar

Related Questions

I've some code that produces a set of tr1::array of different sizes, but same
boost::array<char,7> buf = {'a','b','c','d','e','f','g'}; ... ... std::cout << buf.data() + 5; It's display: fg
I'm looking for a C++ container that's a cross between boost::array, boost::scoped_array and std::vector.
I just found out that boost::array::static_size isn't part of tr1::array, or at least it's
If I make some code like this: boost::array<10> a1; boost::array<20> a2; boost::array<30> a3; Will
#include <iostream> #include <algorithm> #include <vector> #include <boost/array.hpp> #include <boost/bind.hpp> int main() { boost::array<int,
How can I define a array of boost matrices as a member variable? None
I have a Boost.MultiIndex big array about 10Gb. In order to reduce the reading
// BOOST Includes #include <boost/assign.hpp> // Boost::Assign #include <boost/assign/list_of.hpp> // Boost::Assign::List_Of #include <boost/assign/std/map.hpp> //
I am trying to understand the boost array . The code can be read

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.