gpt4 book ai didi

c++ - 如何在 C++ 中使用 Boost::regex.hpp 库?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:57:10 28 4
gpt4 key购买 nike

我尝试使用 Boost 库但失败了,请查看我的代码:

#include "listy.h"
#include <boost/regex.hpp>
using namespace boost;

ListyCheck::ListyCheck() {

}

ListyCheck::~ListyCheck() {

}

bool ListyCheck::isValidItem(std::string &__item) {
regex e("(\\d{4}[- ]){3}\\d{4}");

return regex_match(__item, e);
}

当我尝试编译它时,我得到了这些消息:

/usr/include/boost/regex/v4/regex_match.hpp:50: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator > >, std::allocator, std::allocator > > > >, boost::regex_traits >

::match()'

/usr/include/boost/regex/v4/basic_regex.hpp:425: undefined reference `boost::basic_regex >

::do_assign(char const*, char const*, unsigned int)'

/usr/include/boost/regex/v4/perl_matcher.hpp:366: undefined reference `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::分配器 >>, std::分配器, std::分配器 >> >>, boost::regex_traits >

::construct_init(boost::basic_regex > > const&, boost::regex_constants::_match_flags)'

等...

最佳答案

您需要链接到 libboost_regex。如果您使用的是 gcc,请将 -lboost_regex 添加到编译器开关。

关于c++ - 如何在 C++ 中使用 Boost::regex.hpp 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3021377/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com