Boost C++ Libraries

...one 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.
PrevUpHomeNext
Define a Custom Attribute Mapping for a Generator
create_generator

The template create_generator is a type used as an customization point. It is invoked by the Karma create_generator API function in order to create a custom mapping of the given data type to a generator expression. This generator expression will be returned from create_generator whenever the given data type is encountered.

Module Headers
// forwards to <boost/spirit/home/karma/auto.hpp>
#include <boost/spirit/include/karma_auto.hpp>

Also, see Include Structure.

Namespace

Name

boost::spirit::traits

Synopsis
template <typename T, typename Enable>
struct create_generator
{
    typedef <unspecified> type;
    static type const& call();
};
Template parameters

Parameter

Description

Default

T

The type, T for which a custom mapping to a generator should be established.

none

Enable

Helper template parameter usable to selectively enable or disable certain specializations of create_generator utilizing SFINAE (i.e. boost::enable_if or boost::disable_if).

void

Notation

T

An arbitrary type.

Expression Semantics

Expression

Semantics

create_generator<T>::type

Defines the type of the generator expression returned from call.

create_generator<T>::call()

Returns a generator expression (usually this is a proto::expression) to be used as the default generator for the given type, T.

Predefined Specializations

Spirit predefines specializations of this customization point for several types. All predefined mappings are listed here: Additional Attribute Requirements for Generators.

[Note] Note

It is possible to overload the predefined mappings for the listed types by providing your own specialization of the create_generator customization point for the type to modify.

When to implement

The customization point create_generator needs to be implemented for a specific type whenever this type should be usable with the API function create_generator (which includes using the karma::auto_ generator and the special API functions based on the automatic creation of the matching generator type).

Example

For an example of how to use the customization point create_generator please see here: Example for Using the karma::auto_ Generator.


PrevUpHomeNext