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

Used to select one grammar or another based on the result of a compile-time Boolean. More...

#include <proto_fwd.hpp>

Inheritance diagram for boost::proto::if_< If, Then, Else >:
Collaboration diagram for boost::proto::if_< If, Then, Else >:

Classes

struct  impl
 

Public Types

typedef if_ proto_grammar
 
typedef if_< If, Then, Else > 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 If, typename Then, typename Else>
struct boost::proto::if_< If, Then, Else >

Used to select one grammar or another based on the result of a compile-time Boolean.

When used as a transform, if_<> selects between two transforms based on a compile-time Boolean.

When if_<If,Then,Else> is used as a grammar, If must be a Proto transform and Then and Else must be grammars. An expression type E matches if_<If,Then,Else> if boost::result_of<when<_,If>(E,int,int)>::type::value is true and E matches U; or, if boost::result_of<when<_,If>(E,int,int)>::type::value is false and E matches V.

The template parameter Then defaults to _ and Else defaults to not<_>, so an expression type E will match if_<If> if and only if boost::result_of<when<_,If>(E,int,int)>::type::value is true.

// A grammar that only matches integral terminals,
// using is_integral<> from Boost.Type_traits.
struct IsIntegral
: and_<
terminal<_>
, if_< is_integral<_value>() >
>
{};

When if_<If,Then,Else> is used as a transform, If, Then and Else must be Proto transforms. When applying the transform to an expression E, state S and data V, if boost::result_of<when<_,If>(E,S,V)>::type::value is true then the Then transform is applied; otherwise the Else transform is applied.

// Match a terminal. If the terminal is integral, return
// mpl::true_; otherwise, return mpl::false_.
struct IsIntegral2
: when<
terminal<_>
, if_<
is_integral<_value>()
, mpl::true_()
, mpl::false_()
>
>
{};

Member Typedef Documentation

template<typename If, typename Then, typename Else>
typedef if_ boost::proto::if_< If, Then, Else >::proto_grammar
typedef if_< If, Then, Else > boost::proto::transform< if_< If, Then, Else > , X >::transform_type
inherited

Member Function Documentation

boost::proto::transform< if_< If, Then, Else > , 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< if_< If, Then, Else > , 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< if_< If, Then, Else > , X >::operator() ( Expr &&  e,
State &&  s 
) const
inlineinherited
BOOST_FORCEINLINE boost::proto::detail::apply_transform<transform_type(Expr const &)>::result_type boost::proto::transform< if_< If, Then, Else > , X >::operator() ( Expr &&  e) const
inlineinherited

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