| Home | Libraries | People | FAQ | More

#### Atomically Extract an Attribute Value from a Container (Karma)

###### attribute_as

`attribute_as` atomically extracts an instance of a type from another type. This customization point is used by the `as<T>[]` directive.

###### Module Headers

    #include <boost/spirit/home/support/attributes_fwd.hpp>

Also, see Include Structure.

| Note
This header file does not need to be included directly by any user program as it is normally included by other Spirit header files relying on its content.

###### Namespace

Name
`boost::spirit::traits`

###### Synopsis

    template <typename T, typename Attribute, typename Enable = void>
    struct attribute_as;

###### Template parameters

Parameter | Description | Default
--- | --- | ---
`T` | The type of the attribute natively exposed by the component the `attribute_as` is invoked from. | none
`Attribute` | The type of the attribute to be used to generate output from. | none
`Enable` | Helper template parameter usable to selectively enable or disable certain specializations of `attribute_as` utilizing SFINAE (i.e. `boost::enable_if` or `boost::disable_if`). | `void`

Notation

`attr`

  An instance of type `Attrib`.

###### Expression Semantics

Expression | Semantics
--- | ---
`attribute_as<T, Attribute>::type` | The result type of the extraction.
`attribute_as<T, Attribute>::call(attr)` | Extract and return an instance of `type`.
`attribute_as<T, Attribute>::valid_as(attr)` | Determine, at runtime, if the extraction of an instance of `type` from `attr` would cause an error.

###### Predefined Specializations

Spirit predefines specializations of this customization point for several types. The following table lists those types together with the types exposed and the corresponding semantics:

Template Parameters | Semantics
--- | ---
`unused_type` | The exposed typedef `type` is defined to `unused_type`. The function `call()` returns an instance of `unused_type`.

###### When to implement

This customization point may need to be implemented when using the `as<T>[]` directive.