R
Rich Herrick
The latest version of my "Pascal-like" set class is available here:
http://www.richherrick.com/software/herrick-1.0.zip
Those from the old YAHOO BOOST forum might remember it from several months
back. I have enhanced the code, and "deboostifized" it.
For those unfamiliar with it, it is a template class that implements set
classes that are similar to the set type in the Pascal language. Like
Pascal, any integer (ordinal) type may be used with the set, but I mainly
wrote it for use with enumerations. Set elements are stored at the bit
level, so it is every compact. There is even a member template for defining
set objects as compile-time constants. I wrote it because none of the C++
containers (i.e., set and bitset) suited my needs.
A big change from older versions is the addition of a traits template
parameter for use gaining finer control over the class' behavior for such
things as bit ordering and element range (which defaults to [0,
number-of-elements - 1]).
Examples from documentation:
declaration:
enum color_type
{NON_COLOR = -1, RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET,
NUM_COLORS};
typedef herrick:ascal_set<color_type, NUM_COLORS> color_set;
compile-time constants:
const color_set additive_primaries =
color_set::setof<RED, GREEN, BLUE>::value;
const color_set subtractive_primaries =
color_set::setof<RED, YELLOW, BLUE>::value;
I'd be very interested in comments about the code, the interface (I may have
went overboard on operators!), or my use of templates (I still get hazy on
when to use "typename" and "template").
My goal is to have the interface as much as like the Pascal set type as
feasible, while having the code conform to the lated standard (regardless
particular compiler conformity).
The code currenty compilers with:
GCC 3.4.0 (MinGW)
Visual C++ Toolkit 2003
Rich Herrick
(e-mail address removed)
http://www.richherrick.com/software/herrick-1.0.zip
Those from the old YAHOO BOOST forum might remember it from several months
back. I have enhanced the code, and "deboostifized" it.
For those unfamiliar with it, it is a template class that implements set
classes that are similar to the set type in the Pascal language. Like
Pascal, any integer (ordinal) type may be used with the set, but I mainly
wrote it for use with enumerations. Set elements are stored at the bit
level, so it is every compact. There is even a member template for defining
set objects as compile-time constants. I wrote it because none of the C++
containers (i.e., set and bitset) suited my needs.
A big change from older versions is the addition of a traits template
parameter for use gaining finer control over the class' behavior for such
things as bit ordering and element range (which defaults to [0,
number-of-elements - 1]).
Examples from documentation:
declaration:
enum color_type
{NON_COLOR = -1, RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET,
NUM_COLORS};
typedef herrick:ascal_set<color_type, NUM_COLORS> color_set;
compile-time constants:
const color_set additive_primaries =
color_set::setof<RED, GREEN, BLUE>::value;
const color_set subtractive_primaries =
color_set::setof<RED, YELLOW, BLUE>::value;
I'd be very interested in comments about the code, the interface (I may have
went overboard on operators!), or my use of templates (I still get hazy on
when to use "typename" and "template").
My goal is to have the interface as much as like the Pascal set type as
feasible, while having the code conform to the lated standard (regardless
particular compiler conformity).
The code currenty compilers with:
GCC 3.4.0 (MinGW)
Visual C++ Toolkit 2003
Rich Herrick
(e-mail address removed)