使用 xp::sregex::compile 时 regex_byref_matcher.hpp 的路径

path of regex_byref_matcher.hpp when using xp::sregex::compile

我注意到当我在我的代码中使用 xp::sregex::compile 时,字符串 ...rdparty\boost-1_58\boost/xpressive/detail/core/matcher/regex_byref_matcher.hpp (带有我的本地路径)出现在二进制代码中,在发布模组中编译。 有办法去除吗?

毫无疑问,当代码使用 __FILE__ 来获取不错的 assert/exception 消息时。

Xpressive 直接使用它的唯一地方是 regex_error.hpp:

#define BOOST_XPR_ENSURE_(pred, code, msg)                                                          \
    boost::xpressive::detail::ensure_(!!(pred), code, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)  \
    /**/

你可以很容易地破解它成为

#include <boost/xpressive/regex_error.hpp>

#undef BOOST_XPR_ENSURE_

#define BOOST_XPR_ENSURE_(pred, code, msg)                                                          \
    boost::xpressive::detail::ensure_(!!(pred), code, msg, BOOST_CURRENT_FUNCTION, "(source-hidden)", __LINE__)  \
    /**/

切记:

  • 黑客需要先于任何其他 Xpressive 包括
  • 这将限制消息的有用性,如果它们出现的话
  • Xpressive 所依赖的库之一可能使用类似的结构