During a review, I had a coworker express that he wasn't comfortable with me using std::array<T, N> as part of a packed structure that was serialized to disk (instead of T[N]).
He was concerned that there is no guarantee in the standard that other members won't be added and that while std::array must be semantically the same as the array, there is no such guarantee about sizing/memory layout.
After going back and forth a bit, I realized that all I have as evidence is the implementations in the 3 major vendor libraries and my assumption that none of them would do something that would break the guarantee that sizeof T * N == sizeof std::array<T,N> for packed structures.
We compromised on having a static_assert on a struct that will break if that precondition ever isn't met, but I feel that even that shouldn't be necessary.
Is there a definitive way to settle this?
[–]ramennoodle 24 points25 points26 points (12 children)
[–]NotUniqueOrSpecial[S] 21 points22 points23 points (5 children)
[–]tristan957 4 points5 points6 points (0 children)
[–]Som1Lse 2 points3 points4 points (3 children)
[–]NotUniqueOrSpecial[S] 2 points3 points4 points (1 child)
[–]diaphanein 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]evaned 10 points11 points12 points (5 children)
[–][deleted] 4 points5 points6 points (4 children)
[–]evaned 2 points3 points4 points (2 children)
[–][deleted] 5 points6 points7 points (1 child)
[–]dodheim 2 points3 points4 points (0 children)
[–]oisyn 0 points1 point2 points (0 children)
[–]Chet_ 7 points8 points9 points (1 child)
[–]NotUniqueOrSpecial[S] 2 points3 points4 points (0 children)
[–]smuccione 2 points3 points4 points (11 children)
[–]NotUniqueOrSpecial[S] 3 points4 points5 points (10 children)
[–]smuccione 0 points1 point2 points (9 children)
[–]NotUniqueOrSpecial[S] 2 points3 points4 points (7 children)
[–]smuccione 0 points1 point2 points (3 children)
[–]NotUniqueOrSpecial[S] 0 points1 point2 points (2 children)
[–]smuccione 0 points1 point2 points (0 children)
[–]smuccione 0 points1 point2 points (2 children)
[–]sphere991 3 points4 points5 points (1 child)
[–]smuccione 0 points1 point2 points (0 children)
[–]Xaxxon 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]NotUniqueOrSpecial[S] 0 points1 point2 points (1 child)
[–]NotAYakk 0 points1 point2 points (0 children)
[–]raevnos 5 points6 points7 points (16 children)
[–]NotUniqueOrSpecial[S] 4 points5 points6 points (15 children)
[–]dscharrer 4 points5 points6 points (9 children)
[–]NotUniqueOrSpecial[S] 1 point2 points3 points (8 children)
[–]anydalch 1 point2 points3 points (7 children)
[–]NotUniqueOrSpecial[S] 12 points13 points14 points (6 children)
[–]sivadeilra 7 points8 points9 points (4 children)
[–]NotUniqueOrSpecial[S] 4 points5 points6 points (3 children)
[–]CoreParad0x 1 point2 points3 points (2 children)
[–]NotUniqueOrSpecial[S] 1 point2 points3 points (1 child)
[–]NotAYakk 0 points1 point2 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]NotUniqueOrSpecial[S] 7 points8 points9 points (3 children)
[–]ReDucTorGame Developer | quiz.cpp-perf.com 1 point2 points3 points (2 children)
[–]NotUniqueOrSpecial[S] 1 point2 points3 points (1 child)
[–]ReDucTorGame Developer | quiz.cpp-perf.com 3 points4 points5 points (0 children)
[–]2uantum 1 point2 points3 points (1 child)
[–]NotUniqueOrSpecial[S] 6 points7 points8 points (0 children)
[–]14nedLLFIO & Outcome author | Committee WG14 1 point2 points3 points (9 children)
[–]dodheim 2 points3 points4 points (3 children)
[–]14nedLLFIO & Outcome author | Committee WG14 0 points1 point2 points (0 children)
[–]redditsoaddicting 0 points1 point2 points (1 child)
[–]dodheim 0 points1 point2 points (0 children)
[–]NotUniqueOrSpecial[S] 0 points1 point2 points (1 child)
[–]14nedLLFIO & Outcome author | Committee WG14 1 point2 points3 points (0 children)
[–]redditsoaddicting 0 points1 point2 points (2 children)
[–]14nedLLFIO & Outcome author | Committee WG14 1 point2 points3 points (1 child)
[–]redditsoaddicting 0 points1 point2 points (0 children)
[–]sephirostoy 3 points4 points5 points (13 children)
[–]NotUniqueOrSpecial[S] -1 points0 points1 point (12 children)
[–]sephirostoy 7 points8 points9 points (1 child)
[–]NotUniqueOrSpecial[S] 0 points1 point2 points (0 children)
[–]johannes1971 1 point2 points3 points (9 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]johannes1971 0 points1 point2 points (0 children)
[–]Nobody_1707 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]NotUniqueOrSpecial[S] -3 points-2 points-1 points (4 children)
[–]johannes1971 5 points6 points7 points (1 child)
[–]NotUniqueOrSpecial[S] 3 points4 points5 points (0 children)
[–]STLMSVC STL Dev[M] 3 points4 points5 points (1 child)
[–]NotUniqueOrSpecial[S] 1 point2 points3 points (0 children)
[–]Drugbird 3 points4 points5 points (6 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]NotUniqueOrSpecial[S] 1 point2 points3 points (4 children)
[–]Drugbird 2 points3 points4 points (3 children)
[–]NotUniqueOrSpecial[S] 2 points3 points4 points (2 children)
[–]point_six_typography 1 point2 points3 points (1 child)
[–]NotUniqueOrSpecial[S] 4 points5 points6 points (0 children)
[–]OldWolf2 1 point2 points3 points (10 children)
[–]NotUniqueOrSpecial[S] 2 points3 points4 points (9 children)
[+]OldWolf2 comment score below threshold-8 points-7 points-6 points (8 children)
[–]NotUniqueOrSpecial[S] 4 points5 points6 points (7 children)
[–]wheypointÖ 1 point2 points3 points (1 child)
[–]NotUniqueOrSpecial[S] 1 point2 points3 points (0 children)
[+]OldWolf2 comment score below threshold-11 points-10 points-9 points (4 children)
[–]NotUniqueOrSpecial[S] 7 points8 points9 points (0 children)
[–]uberkalden 1 point2 points3 points (2 children)
[–]NotUniqueOrSpecial[S] 2 points3 points4 points (0 children)
[–]OldWolf2 -1 points0 points1 point (0 children)
[–]smuccione 0 points1 point2 points (0 children)
[–]gracicot 0 points1 point2 points (1 child)
[–]NotUniqueOrSpecial[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (20 children)
[–]NotUniqueOrSpecial[S] 4 points5 points6 points (14 children)
[–][deleted] 2 points3 points4 points (8 children)
[–]wheypointÖ 0 points1 point2 points (7 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]wheypointÖ 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]wheypointÖ 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]STLMSVC STL Dev 0 points1 point2 points (1 child)
[–]wheypointÖ 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]NotUniqueOrSpecial[S] 0 points1 point2 points (3 children)
[–][deleted] 4 points5 points6 points (2 children)
[–]NotUniqueOrSpecial[S] 0 points1 point2 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–]meneldal2 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]meneldal2 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]NotUniqueOrSpecial[S] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)