C++ (Qt)struct A { int m_B; short m_C; ... char m_Z;};
C++ (Qt)void A::ReadWrite( CBitStream & stream, TMode mode ) { stream.ReadWriteInt(&m_B, 4, mode); stream.ReadWriteShort(&m_C, 12, mode); ... stream.ReadWriteChar(&m_Z, 7, mode);}
C++ (Qt)template<N, S>struct Field { bool v // if N == 1 int8_t v // if N <= 8 && S=signed uint8_t v // if N <= 8 && S=unsigned ...};
template <class To, class From>typename std::enable_if_t< sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> && std::is_trivially_copyable_v<To>, To>// constexpr support needs compiler magicbit_cast(const From& src) noexcept{ static_assert(std::is_trivially_constructible_v<To>, "This implementation additionally requires destination type to be trivially constructible"); To dst; std::memcpy(&dst, &src, sizeof(To)); return dst;}
union U { int i{0}; float f{0};};int foo(){ U u; u.i = -1; u.f = 0.0f; return u.i; // 0 или -1?}
untitled 2:4:11: error: initializing multiple members of union float f{0}; ^untitled 2:3:9: note: previous initialization is here int i{0}; ^1 error generated.
C++ (Qt)std::array c = {std::byte{0}, std::byte{0x78}, std::byte{0x2}};
for field in mystruct.orderedFields stream.write(field.size, field.value);
C++ (Qt) struct record { bit_field<1> flag; bit_field<4> mode; bit_field<9> address; bit_array pack() const { return ::pack( flag, mode, address ); } static record unpack( const bit_array &src ) { record result; ::unpack( src, result.flag, result.mode, result.address ); return result; } };