sizeof std::tr1::array

Aaron Graham
Wed Oct 24 04:33:00 GMT 2007

This has probably been discussed before, but I can't find any information on it.

Unlike boost::array, std::tr1::array (and std::array in 4.3.x) has an
attribute-alignment on its data, which means that sizeof(the_array) is
always a multiple of 16, at least on all systems I'm currently using:

    value_type _M_instance[_Nm ? _Nm : 1] __attribute__((__aligned__));

This is rather inconvenient, and somewhat unnecessary, especially on
embedded systems, since there's a nontrivial hidden cost here.  I have
a harder time convincing programmers not to roll-their-own when I see
stuff like that.

Can I get an explanation please?
Thanks in advance.

More information about the Libstdc++ mailing list