Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
API for Automatic Parser Creation

The library implements a special API returning a parser instance for a supplied attribute type. This function finds the best matching parser type for the attribute based on a set of simple matching rules (as outlined in the table below) applied recursively to the attribute type. The returned parser can be utilized to match input for the provided attribute.

// forwards to <boost/spirit/home/qi/auto.hpp>
#include <boost/spirit/include/qi_auto.hpp>

Also, see Include Structure.





namespace boost { namespace spirit { namespace qi
    template <typename Attr>
    inline <unspecified>

The returned instance can be directly passed as the parser (or the skipping parser) to any of the Spirit.Qi API functions. Additionally it can be assigned to a rule as the rules right hand side expression. This function will return a valid parser type only if the meta function traits::create_parser_exists returns mpl::true_. Otherwise it will fail compiling.

namespace boost { namespace spirit { namespace traits
    template <typename Attr>
    struct create_parser_exists;

The meta function evaluates to mpl::true_ if create_parser would return a valid parser for the given type Attr.

The following table outlines the mapping rules from the attribute type to the parser type. These rules are applied recursively to create the parser type which can be used to match input for the given attribute type.

Attribute type

Generator type

char, wchar_t

standard::char_, standard_wide::char_

short, int, long

short_, int_, long_

unsigned short, unsigned int, unsigned long

ushort_, uint_, ulong_

float, double, long double

float_, double_, long_double

short, int, long

short_, int_, long_

long long, unsigned long long

long_long, ulong_long



Any (STL) container

Kleene Star (unary '*')

Any Fusion sequence

Sequence operator ('>>')


Optional operator (unary '-')


Alternative operator ('|')

[Important] Important

The mapping for the parsers long_long and ulong_long are only available on platforms where the preprocessor constant BOOST_HAS_LONG_LONG is defined (i.e. on platforms having native support for long long and unsigned long long (64 bit) signed and unsigned integer types).

Template parameters




An attribute type utilized to create the corresponding parser type from.