Next: , Previous: C++ Sequence, Up: C++ mappings


6.2.10 Mapping for optional types

GenoM IDL optional types map onto the genom::optional template class.

For instance, the following IDL:

      typedef optional< long > opt;

would map into

      typedef genom::optional< int32_t > opt;

The interface of genom::optional is the following:

  template <typename T>
  struct optional {
    // types:
    typedef T                                     value_type;
    typedef value_type&                           reference;
    typedef const value_type&                     const_reference;

    bool _present;
    value_type _value;
  };

The _present member, when true, indicates the presence of valid data in _value. When _present is false, the _value should be ignored.