System.Set.Create
C++
__fastcall Set() {memset(SetBaseT::Data, 0, sizeof (SetBaseT::Data));}
__fastcall Set(const Set& src)
explicit __fastcall Set(const int& src)
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
constructor | public | sysset.h | System | Set |
Description
Set is a C++ template for emulating the set types found in Delphi.
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 Set type, use a typedef expression.
typedef Set <char, 'A','Z'> UPPERCASESet;
The declaration of a 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
Note: To utilize the C++ streaming operators (<< and >>) with Set types, you must use #include <iostream> before #include <sysset.h>. This occurs automatically if you include vcl.h, or System.hpp. The following stream operators are defined:
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)