Container hierarchy vs. container types
dsimcha
dsimcha at yahoo.com
Thu Mar 4 21:09:46 PST 2010
== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> Hi everyone,
> I'm on a trip to Romania visiting relatives. Being disconnected for a
> while, I thought some about container types and started writing some code.
> It didn't take long to figure that a classic class hierarchy with
> inheritance etc. would contain prohibitively many types (with awkward
> names too), or would lose a lot of expressiveness. There are just so
> many types of containers, and they have so different characteristics.
> My second shot was with a capability-based architecture suggested (in an
> unrelated context) by Scott Meyers
> (http://www.artima.com/cppsource/codefeatures.html - good article,
> recommended regardless). Some capabilities I came up with were:
> enum ContCaps : uint
> {
> hasLength = 1,
> hasAssignableLength = 2,
> hasPushBack = 4,
> hasRemoveBack = 8,
> hasPushFront = 16,
> hasRemoveFront = 32,
> linear = 64,
> hasFront = 128,
> hasBack = 256,
> randomAccess = 512,
> }
This is why I hate nominative typing
(http://en.wikipedia.org/wiki/Nominative_type_system).
More information about the Digitalmars-d
mailing list