set

| Home | Libraries | People | FAQ | More

### set

##### Description

set is an Associative Sequence of heterogeneous typed data elements. Type identity is used to impose an equivalence relation on keys. The element's type is its key. A set may contain at most one element for each key. Membership testing and element key lookup has constant runtime complexity (see Overloaded Functions).

##### Header

    #include <boost/fusion/container/set.hpp>
    #include <boost/fusion/include/set.hpp>
    #include <boost/fusion/container/set/set_fwd.hpp>
    #include <boost/fusion/include/set_fwd.hpp>

##### Synopsis

    template <
        typename T0 = unspecified
      , typename T1 = unspecified
      , typename T2 = unspecified
        ...
      , typename TN = unspecified
    >
    struct set;

For C++11 compilers, the variadic function interface has no upper bound.

For C++03 compilers, the variadic class interface accepts `0` to `FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that defaults to `10`. Example:

    set<int, char, double>

You may define the preprocessor constant `FUSION_MAX_SET_SIZE` before including any Fusion header to change the default. Example:

    #define FUSION_MAX_SET_SIZE 20

##### Template parameters

Parameter | Description | Default
--- | --- | ---
`T0`...`TN` | Element types | unspecified

##### Model of

- Associative Sequence
- Forward Sequence

Notation

`S`

  A `set` type

`s`

  An instance of `set`

`e0`...`en`

  Heterogeneous values

`fs`

  A Forward Sequence

##### Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in Random Access Sequence and Associative Sequence.

Expression | Semantics
--- | ---
`S()` | Creates a set with default constructed elements.
`S(e0, e1,... en)` | Creates a set with elements `e0`...`en`.
`S(fs)` | Copy constructs a set from a Forward Sequence `fs`.
`s = fs` | Assigns to a set, `s`, from a Forward Sequence `fs`.

##### Example

    typedef set<int, float> S;
    S s(12, 5.5f);
    std::cout << at_key<int>(s) << std::endl;
    std::cout << at_key<float>(s) << std::endl;
    std::cout << result_of::has_key<S, double>::value << std::endl;