Is it always safe to replace an inline array with an array of std / tr1 / boost ::?

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

So far, our code base has contained only built-in arrays, for example (composed, but the style is consistent):

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

I think you will understand this idea.

Now, my question is that for those places in the code where dropping in boost::arraymakes sense (due to other changes), is there a array100% semantics that keeps the insert for the inline array? (Possible compiler errors are fine - I am only concerned about silent behavioral changes.)

That is, if the code above was rewritten (for example) to use:

boost::array<WORD, FLAGS_MAX> m_lastReadFlags;

memcpy (, c_array() data()) ? , , memcpy std::copy - , .


. , - (, memcpy), . / ?

?

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;
...
+5
1

, , array - . , , , . std::copy ; , memcpy.

array ( //), (), .

+5

All Articles