![]() |
Home | Libraries | People | FAQ | More |
boost::proto::protect — A PrimitiveTransform which prevents another PrimitiveTransform from being applied in an ObjectTransform.
// In header: <boost/proto/transform/make.hpp> template<typename PrimitiveTransform> struct protect : proto::transform< { // member classes/structs/unions template<typename , typename , typename > struct impl { // types typedef ; }; };
When building higher order transforms with
proto::make<>
or
proto::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
proto::_
in
Bar<proto::_>()
with proto::terminal<int>::type
:
proto::when<proto::_, proto::_>() > {}; proto::terminal<
If you actually wanted to default-construct an object of type
Bar<proto::_>
, you would have to protect the
_
to prevent it from being applied. You can
use proto::protect<>
as follows:
// OK: replace anything with Bar<_>() proto::when<proto::_, proto::protect<proto::_> >() > {};