boost::proto::or_ — 用于匹配一组备选语法中的一个。备选项按顺序尝试以避免歧义。当用作转换时,proto::or_<> 应用与匹配表达式的第一个语法关联的转换。
// In header: <boost/proto/matches.hpp>
template<typename... G>
struct or_ : proto::transform<or_<G...> > {
// types
typedef or_ proto_grammar;
// member classes/structs/unions
template<typename Expr, typename State, typename Data>
struct impl : proto::transform_impl< Expr, State, Data > {
// types
typedef unspecified result_type;
// public member functions
result_type operator()(typename impl::expr_param,
typename impl::state_param,
typename impl::data_param) const;
};
};表达式类型 E 匹配 proto::or_<G0,G1,...Gn>,如果 E 匹配任何 Gx,其中 x 在 [0,n] 中。
当使用 proto::or_<G0,G1,...Gn> 作为转换,对类型为 E 的表达式 e、状态 s 和数据 d 应用时,它等效于 Gx()(e, s, d),其中 x 是满足 proto::matches<E, Gx>::value 为 true 的最小数字。
结构体模板 proto::or_<> 接受的最大模板参数数量由 BOOST_PROTO_MAX_LOGICAL_ARITY 宏控制。