Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::proto::call< PrimitiveTransform > Struct Template Reference

Wrap PrimitiveTransform so that when<> knows it is callable. More...

#include <call.hpp>

Inheritance diagram for boost::proto::call< PrimitiveTransform >:
Collaboration diagram for boost::proto::call< PrimitiveTransform >:

Detailed Description

template<typename PrimitiveTransform>
struct boost::proto::call< PrimitiveTransform >

Wrap PrimitiveTransform so that when<> knows it is callable.

Requires that the parameter is actually a PrimitiveTransform.

This form of call<> is useful for annotating an arbitrary PrimitiveTransform as callable when using it with when<>. Consider the following transform, which is parameterized with another transform.

template<typename Grammar>
struct Foo
: when<
unary_plus<Grammar>
, Grammar(_child) // May or may not work.
>
{};

The problem with the above is that when<> may or may not recognize Grammar as callable, depending on how Grammar is implemented. (See is_callable<> for a discussion of this issue.) You can guard against the issue by wrapping Grammar in call<>, such as:

template<typename Grammar>
struct Foo
: when<
unary_plus<Grammar>
, call<Grammar>(_child) // OK, this works
>
{};

The above could also have been written as:

template<typename Grammar>
struct Foo
: when<
unary_plus<Grammar>
, call<Grammar(_child)> // OK, this works, too
>
{};

The documentation for this struct was generated from the following file: