On Tue, 22 Sep 2009 00:03:28 +0400, Andrei Alexandrescu <[email protected]> wrote:

dsimcha wrote:
I'm thinking it might be useful to have a library type that allows for
arbitrary size integers <= 64 bits (128 if ucent is ever implemented) to be packed into an array. This might be nice when you want a huge array of them, the size you actually need is somewhere in between two native sizes, and you care more about space/cache efficiency than raw CPU cycles. For example, let's say you wanted an array of N 19-bit integers. You'd make an array of uints (32-bit) with ceil(N * 19 / 32) elements, and when it was indexed, you'd do a bunch of modulus and bit shifting to get the right 19 bits out of that block of memory, and return a uint. It would be slow as molasses, but really
space efficient, which would in certain cases be a reasonable tradeoff.
Has anyone implemented, or considered implementing this before? If not, if I
implemented it well and submitted it as an enhancement, would it be a
reasonable thing to include in std.array?

I think that would be a nice addition. We haven't established some general rules for containers. Values or references? In the latter case: Classes or structs? If classes: hierarchy or largely independent classes?

Andrei

You can't implement containers using structs unless default ctors for them are allowed.
Is it ever going to be fixed?

Reply via email to