The attr_cast<Exposed,Transformed>()
component invokes the embedded generator while supplying an attribute
of type Transformed.
The supplied attribute gets created from the original attribute (of type
Exposed) passed to this
component using the customization point traits::transform_attribute.

Semantics of an expression is defined only where it differs from, or
is not defined in UnaryGenerator.

Expression

Semantics

attr_cast(g)

Create a component invoking the generator g
while passing an attribute of the type as normally expected
by g. The type
of the supplied attribute will be transformed to the type
g exposes as
its attribute type (by using the attribute customization point
traits::transform_attribute).
This generator does not fail unless g
fails.

attr_cast<Exposed>(g)

Create a component invoking the generator g
while passing an attribute of the type as normally expected
by g. The supplied
attribute is expected to be of the type Exposed,
it will be transformed to the type g
exposes as its attribute type (using the attribute customization
point traits::transform_attribute).
This generator does not fail unless g
fails.

attr_cast<Exposed,Transformed>(g)

Create a component invoking the generator g
while passing an attribute of type Transformed.
The supplied attribute is expected to be of the type Exposed, it will be transformed
to the type Transformed
(using the attribute customization point traits::transform_attribute).
This generator does not fail unless g
fails.

// this is just a test structure we want to use in place of an intstructint_data{inti;};// we provide a custom attribute transformation to allow its use as an intnamespaceboost{namespacespirit{namespacetraits{template<>structtransform_attribute<int_dataconst,int,karma::domain>{typedefinttype;staticintpre(int_dataconst&d){returnd.i;}};}}}

Now we use the attr_cast
pseudo generator to invoke the attribute transformation: