| Home | Libraries | People | FAQ | More

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

###### assign_to_container_from_value

The template `assign_to_container_from_value` is a type used as an attribute customization point. It is invoked by all primitive Qi parsers in order to store a parsed attribute value into the attribute instance provided by the user, if this attribute is a container type (`is_container<T>::type` evaluates to `mpl::true_`, where `T` is the attribute type).

###### 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_container_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. This type is a container type (`is_container<Attrib>::type` evaluates to `mpl::true_`). | 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_container_from_value` utilizing SFINAE (i.e. `boost::enable_if` or `boost::disable_if`). | `void`

Notation

`Attrib`

  A type to be used as the target to store the attribute value in. This type is guaranteed to be a container type (`is_container<Attrib>::type` evaluates to `mpl::true_`).

`attr`

  An attribute instance of type `Attrib`.

`T`

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

`t`

  An attribute instance of type `T`.

###### Expression Semantics

Expression | Semantics
--- | ---
    assign_to_container_from_value<Attrib, T>::call(t, attr)
| Add the value `t` to the container attribute `attr`.

###### Predefined Specializations

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

###### When to implement

The customization point `assign_to_container_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.