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

A PrimitiveTransform which prevents another PrimitiveTransform from being applied in an ObjectTransform. More...

#include <make.hpp>

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

Classes

struct  impl
 

Public Types

typedef protect
< PrimitiveTransform > 
transform_type
 

Public Member Functions

 BOOST_PROTO_CALLABLE () typedef X proto_is_transform_
 
BOOST_FORCEINLINE
boost::proto::detail::apply_transform
< transform_type(Expr const &)>
::result_type 
operator() (Expr &&e) const
 
BOOST_FORCEINLINE
boost::proto::detail::apply_transform
< transform_type(Expr const
&, State const &)>
::result_type 
operator() (Expr &&e, State &&s) const
 
BOOST_FORCEINLINE
boost::proto::detail::apply_transform
< transform_type(Expr const
&, State const &, Data const &)>
::result_type 
operator() (Expr &&e, State &&s, Data &&d) const
 

Detailed Description

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

A PrimitiveTransform which prevents another PrimitiveTransform from being applied in an ObjectTransform.

When building higher order transforms with make<> or lazy<>, you sometimes would like to build types that are parameterized with Proto transforms. In such lambda-style transforms, Proto will unhelpfully find all nested transforms and apply them, even if you don't want them to be applied. Consider the following transform, which will replace the _ in Bar<_>() with proto::terminal<int>::type:

template<typename T>
struct Bar
{};
struct Foo
: proto::when<_, Bar<_>() >
{};
int main()
{
Foo()(i);
std::cout << typeid(Foo()(i)).name() << std::endl;
}

If you actually wanted to default-construct an object of type Bar<_>, you would have to protect the _ to prevent it from being applied. You can use proto::protect<> as follows:

// OK: replace anything with Bar<_>()
struct Foo
: proto::when<_, Bar<protect<_> >() >
{};

Member Typedef Documentation

typedef protect< PrimitiveTransform > boost::proto::transform< protect< PrimitiveTransform > , X >::transform_type
inherited

Member Function Documentation

boost::proto::transform< protect< PrimitiveTransform > , X >::BOOST_PROTO_CALLABLE ( )
inherited
BOOST_FORCEINLINE boost::proto::detail::apply_transform<transform_type(Expr const &, State const &, Data const &)>::result_type boost::proto::transform< protect< PrimitiveTransform > , X >::operator() ( Expr &&  e,
State &&  s,
Data &&  d 
) const
inlineinherited
BOOST_FORCEINLINE boost::proto::detail::apply_transform<transform_type(Expr const &, State const &)>::result_type boost::proto::transform< protect< PrimitiveTransform > , X >::operator() ( Expr &&  e,
State &&  s 
) const
inlineinherited
BOOST_FORCEINLINE boost::proto::detail::apply_transform<transform_type(Expr const &)>::result_type boost::proto::transform< protect< PrimitiveTransform > , X >::operator() ( Expr &&  e) const
inlineinherited

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