System::Set is a C++ template for emulating the set types found in Delphi.
System::Set is a template for declaring set types compatible with Delphi "set of" types.
A set type is declared with three parameters:
Parameter |
Usage |
T |
the type of the elements (usually int, char, or an enum type) |
minEl |
the minimum value the set can hold (this value cannot be less than 0) |
maxEl |
the maximum value the set can hold (this value cannot be greater than 255) |
Two set types are distinct if any of the three template parameters are different:
Set <char, 'A', 'C'> s1; Set <char, 'X', 'Z'> s2; if (s1 == s2) // ERROR: == not implemented for second set type
To create multiple instances of a System::Set type, use a typedef expression.
typedef Set <char, 'A','Z'> UPPERCASESet;
The declaration of a System::Set variable does not initialize the variable. You can declare the set types and initialize them by using the << operator, as shown in this example:
UPPERCASESet s1; s1 << 'A' << 'B' << 'C'; // Initialize UPPERCASESet s2; s2 << 'X' << 'Y' << 'Z'; // Initialize
template <class T, unsigned char minEl, unsigned char maxEl> ostream& operator <<(ostream& os, const Set<T, minEl, maxEl> & arg); template <class T, unsigned char minEl, unsigned char maxEl> istream& operator >> (istream& is, Set<T, minEl, maxEl> & arg)
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|