Menu

#5 policy composite

open
nobody
None
5
2005-08-23
2005-08-23
Larry Evans
No

Variants (or disjoint sum) and tuples (or cartesion
product)
are very similar. They're "duals" in category theory
(http://en.wikipedia.org/wiki/Coproduct ). So their
implementation in template metaprogramming should
have some similarity. After all, each is formed from
a TypeList. The only difference is the storage required
by the Variant is the maximum of the storage required
by the TypeList elements, and the storage required
by the tuple is the sum of the storage required by the
TypeList elements.

What I'm proposing is that the implementations of
would only differ in the storage policies and
projection/injection polcies. In addition, there could
be a base tuple and variant which may be derived
by adding methods specialized for whether the
variant or tuple is the base. An example of this is
that proposed here:

http://groups-beta.google.com/group/comp.std.c++/msg/27e41e693228c6c7?hl=en&

This all could be implemented using something like
the fold template mentioned here:

http://sourceforge.net/forum/message.php?msg_id=1856879

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.