Пример #1
0
        inline namespace v5
        {
            namespace detail
            {
                ////////////////////////////////////////////////////////////////////////////////////
                // return_
                using return_ = utility::identity;

                ////////////////////////////////////////////////////////////////////////////////////
                template<typename Action>
                struct call_action_
                {
                    template<typename ...Args, typename A = Action>
                    constexpr auto operator()(Args &&... args) const
                    BOOST_PROTO_AUTO_RETURN(
                        BOOST_PROTO_TRY_CALL(as_action_<A>())(static_cast<Args &&>(args)...)
                    )
                };

                ////////////////////////////////////////////////////////////////////////////////////
                struct not_an_action
                {};

                ////////////////////////////////////////////////////////////////////////////////////
                template<typename BoolAction, typename ...Args>
                struct eval_bool_action_
                  : std::integral_constant<
                        bool
                      , static_cast<bool>(
                            std::remove_reference<
                                decltype(call_action_<BoolAction>()(std::declval<Args>()...))
Пример #2
0
            /// matches all \c Bx for \c x in <tt>[0,n)</tt>.
            ///
            /// When applying <tt>and_\<B0,B1,...Bn\></tt> as a basic_action with an
            /// expression \c e, state \c s and data \c d, it is
            /// equivalent to <tt>(B0()(e, s, d),B1()(e, s, d),...Bn()(e, s, d))</tt>.
            namespace detail
            {
                template<typename... Actions>
                struct _block
                  : basic_action<_block<Actions...>>
                {
                    template<typename ...Args>
                    constexpr auto operator()(Args &&... args) const
                    BOOST_PROTO_AUTO_RETURN(
                        BOOST_PROTO_TRY_CALL(utility::functional::back())(
                            (call_action_<Actions>()(static_cast<Args &&>(args)...), utility::void_)...
                        )
                    )
                };
            }

            struct block
            {};

            namespace extension
            {
                template<typename... Actions>
                struct action_impl<block(Actions...)>
                  : detail::_block<Actions...>
                {};
            }
Пример #3
0
                    // If the Tag action creates an expression, use functional::make_expr with
                    // a safe version of the deduced domain instead to avoid dangling references.
                    template<
                        typename ...Ts
                      , typename ThisTag = Tag
                      , typename MakeExpr =
                            functional::make_expr<
                                ThisTag
                              , domains::safe_domain_adaptor<deduce_domain>
                            >
                      , BOOST_PROTO_ENABLE_IF(
                            ThisTag::proto_arity_type::equal_to(sizeof...(Ts))
                        )
                      , BOOST_PROTO_ENABLE_IF(
                            v5::is_expr<
                                decltype(BOOST_PROTO_TRY_CALL(ThisTag())(std::declval<Ts>()...))
                            >::value
                        )
                    >
                    constexpr auto operator()(Ts &&...ts) const
                    BOOST_PROTO_AUTO_RETURN(
                        MakeExpr()(static_cast<Ts &&>(ts)...)
                    )

                    // If the Tag action doesn't create an expression, just use it as-is.
                    template<
                        typename ...Ts
                      , typename ThisTag = Tag
                      , BOOST_PROTO_ENABLE_IF(
                            ThisTag::proto_arity_type::equal_to(sizeof...(Ts))
                        )