write_vector_vector(BitWriter& w,
		    int nitems1, std::vector<T>& vec1, int T::*nitems2,
		    int bits, std::vector<int> T::*vec2)
{
    // nitems1 times, write nitems2 (from the ith element of vec1) items
    // from the vec2 vector field of the ith item of vec1.
    for (size_t i1 = 0; i1 < QIntC::to_size(nitems1); ++i1)
    {
	for (size_t i2 = 0; i2 < QIntC::to_size(vec1.at(i1).*nitems2); ++i2)
	{
	    w.writeBits(QIntC::to_ulonglong((vec1.at(i1).*vec2).at(i2)),
                        QIntC::to_size(bits));
	}
    }
    w.flush();
}
write_vector_vector(BitWriter& w,
		    int nitems1, std::vector<T>& vec1, int T::*nitems2,
		    int bits, std::vector<int> T::*vec2)
{
     
     
    for (size_t i1 = 0; i1 < QIntC::to_size(nitems1); ++i1)
    {
	for (size_t i2 = 0; i2 < QIntC::to_size(vec1.at(i1).*nitems2); ++i2)
	{
	    w.writeBits(QIntC::to_ulonglong((vec1.at(i1).*vec2).at(i2)),
                        QIntC::to_size(bits));
	}
    }
    w.flush();
}