| Home | Libraries | People | FAQ | More

##### Store an Attribute Value after a Parser Produced a Value (Qi)

###### assign_to_attribute_from_value

The template `assign_to_attribute_from_value` is a type used as an attribute customization point. It is invoked by the all primitive Qi parsers in order to store a parsed attribute value into the attribute instance provided by the user.

###### Module Headers

    #include <boost/spirit/home/qi/detail/assign_to.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 Attrib, typename T, typename Enable>
    struct assign_to_attribute_from_value
    {
        static void call(T const& val, Attrib& attr);
    };

###### Template parameters

Parameter | Description | Default
--- | --- | ---
`Attrib` | The type, `Attrib` is the type of the attribute as passed in by the user. | none
`T` | The type, `T` is the type of the attribute instance as produced by the parser. | none
`Enable` | Helper template parameter usable to selectively enable or disable certain specializations of `assign_to_attribute_from_value` utilizing SFINAE (i.e. `boost::enable_if` or `boost::disable_if`). | `void`

###### Notation

Notation

`Attrib`

  A type to be used as the target to store the attribute value in.

`attr`

  A attribute instance of type `Attrib`.

`T`

  A type as produced by the parser. The parser temporarily stores its parsed values using this type.

`t`

  A attribute instance of type `T`.

###### Expression Semantics

Expression | Semantics
--- | ---
    assign_to_attribute_from_value<Attrib, T>::call(t, attr)
| Copy (assign) the value, `t` to the attribute `attr`.

###### Predefined Specializations

Template Parameters | Semantics
--- | ---
`Attrib`, `T` | Assign the argument `t` to `attr`.
`unused_type`, `T` | Do nothing.

###### When to implement

The customization point `assign_to_attribute_from_value` needs to be implemented for a specific type whenever the default implementation as shown above is not applicable. Examples for this could be that the type `Attrib` is not copy constructible.

###### Example

TBD