Boost C++ 库

...世界上最受推崇和设计精良的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu,《C++ 编码规范

函数模板 as_xpr - Boost C++ 函数库
PrevUpHomeNext

函数模板 as_xpr

boost::xpressive::as_xpr — 将字面量转换为正则表达式。

提要

// In header: <boost/xpressive/regex_primitives.hpp>


template<typename Literal> unspecified as_xpr(Literal const & literal);

描述

使用 as_xpr() 将字面量转换为正则表达式。例如,“foo” >> “bar” 将无法编译,因为右移运算符的两个操作数都是 const char*,而不存在这样的运算符。请使用 as_xpr("foo") >> "bar" 代替。

除了字符串字面量,您还可以使用 as_xpr() 与字符字面量。例如,as_xpr('a') 将匹配一个 'a'。您还可以补全一个字符字面量,例如 ~as_xpr('a')。这将匹配任何不是 'a' 的单个字符。


PrevUpHomeNext