mirror hosted by tehsausage.com
PTypes: cset: operators

C++ Portable Types Library (PTypes) Version 2.1


Top: Basic types: cset: Operators

#include <ptypes.h>

class cset {
    // assignment
    cset& operator =(const cset& s);

    // union
    cset& operator +=(const cset& s);
    cset& operator +=(char b);
    cset  operator +(const cset& s) const;
    cset  operator +(char b) const;
    friend cset operator +(char b, const cset& s);

    // difference
    cset& operator -=(const cset& s);
    cset& operator -=(char b);
    cset  operator -(const cset& s) const;
    cset  operator -(char b) const;

    // intersection
    cset& operator *=(const cset& s);
    cset  operator *(const cset& s) const;

    // comparison
    bool operator ==(const cset& s) const;
    bool operator !=(const cset& s) const;
    bool operator <=(const cset& s) const;
    bool operator >=(const cset& s) const;

    // membership
    friend bool operator& (char b, const cset& s);
}

The following rules apply to +, -, and *:

The following rules apply to comparison operations <=, >=, ==, !=:

For an ordinal O and a set S, O & S is true just in case O is a member of S. Unlike the Pascal language, where membership operator is in, PTypes uses ampersand "&" as a membership test operator.

Note: regardless of whether default char is signed or unsigned (usually set through compiler options) cset always treats char arguments as unsigned. This means, if the value of an argument is -1, e.g. in call to operator & or operator +, the value will be converted to 255, -2 will be treated as 254, etc.

See also: Constructors, Manipulation


PTypes home