...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The template clear_value
is a type used as an attribute customization point. It is invoked by the
Qi repetitive parsers (Kleene,
Plus, List,
and Repeat)
in order to re-initialize the attribute instance passed to the embedded
parser after it has been stored in the provided container. This re-initialized
attribute instance is reused during the next iteration of the repetitive
parser.
#include <boost/spirit/home/support/attributes.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. |
Name |
---|
|
template <typename Attrib, typename Enable> struct clear_value { static void call(Attrib& val); };
Parameter |
Description |
Default |
---|---|---|
|
The type, |
none |
|
Helper template parameter usable to selectively enable or disable
certain specializations of |
|
Notation
Attrib
A type to be used as a container to store attribute values in.
attr
An attribute instance of type Attrib
.
T1
, T2
, ...Arbitrary types
Expression |
Semantics |
---|---|
clear_value<Attrib>::call(Attrib& attr)
|
Re-initialize the instance referred to by |
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 |
---|---|
|
Re-initialize using assignment of default constructed value. |
Any type |
Call the member function |
|
Clear the |
|
Invoke the |
|
Invoke the |
|
Do nothing. |
The customization point clear_value
needs to be implemented for a specific type whenever this type is to be
used as an attribute to be stored into a STL container and if the type
cannot be re-initialized using one of the specializations listed above.
Examples for this might be types not being default constructible or container
types not exposing a member function clear()
.