简体   繁体   English

'multiline'不是'std :: __ cxx11 :: regex'的成员

[英]‘multiline’ is not a member of ‘std::__cxx11::regex’

I am trying to compile the following C++ code using the command: 我正在尝试使用以下命令编译以下C ++代码:

g++ -std=c++17 -o rgx rgx.cpp

#include <iostream>
#include <regex>
#include <string>
using namespace std;

int main() {
        regex rgx("^([A-Z]*)$", regex::ECMAScript | regex::multiline | regex::icase);
        smatch rmtch;
        string str = "AbcefgH\r\nTest";
        if (regex_match(str, rmtch, rgx)) {
                for (size_t i = 0; i < rmtch.size(); i++) {
                        ssub_match smtch = rmtch[i];
                        string s_m = smtch.str();
                        cout << " submatch " << i << ": " << s_m << endl;
                }
        }
        return 0;
};

However get the following compile time error 但是得到以下编译时错误

rgx.cpp: In function ‘int main()’:
rgx.cpp:7:53: error: ‘multiline’ is not a member of ‘std::__cxx11::regex’ {aka ‘std::__cxx11::basic_regex<char>’}
    7 |  regex rgx("^([A-Z]*)$", regex::ECMAScript | regex::multiline | regex::icase);
g++ --version
g++ (Ubuntu 9.1.0-8ubuntu1) 9.1.0

Why is g++ using __cxx11::regex when I've specified -std=c++17? 当我指定-std = c ++ 17时,为什么g ++使用__cxx11 :: regex?

cppreference.com/w/cpp/regex/basic_regex defines regex::multiline as being part of the C++17 standard cppreference.com/w/cpp/regex/basic_regexregex::multiline定义为C++17标准的一部分

Libstdc++ doesn't appear to implement regex::multiline . Libstdc ++似乎未实现regex::multiline

Note that the fact that it's using std::__cxx11::regex doesn't mean that you're stuck in the past. 请注意,它使用的是std::__cxx11::regex并不意味着您被困在过去。 __cxx11 is not strictly reserved to C++11 features. __cxx11并非严格保留给C ++ 11功能。 The purpose of inline namespaces (such as __cxx11 ) is that if eventually a class/struct needs to change in ways that are not backwards compatible, new programs will grab its definition from a new inline namespace while the old definition remains for programs that were built before. 内联名称空间 (例如__cxx11的目的是,如果最终一个类/结构需要以不向后兼容的方式进行更改,则新程序将从新的内联名称空间中获取其定义,而旧定义仍保留用于已构建的程序之前。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 std::__cxx11::string 转换为 std::string - Converting std::__cxx11::string to std::string 错误:&#39;std::__cxx11::list<User> ::iterator&#39; {aka &#39;struct std::_List_iterator<User> &#39;} 没有名为 XXX 的成员 - error: 'std::__cxx11::list<User>::iterator' {aka 'struct std::_List_iterator<User>'} has no member named XXX (std::__cxx11::string) [T = std::__cxx11::basic_string<char> ; std::__cxx11::string = std::__cxx11::basic_string<char> ] 不能重载 - (std::__cxx11::string) [with T = std::__cxx11::basic_string<char>; std::__cxx11::string = std::__cxx11::basic_string<char>] cannot be overloaded cpp:错误:'类提升::可选<std::__cxx11::basic_string<char> &gt;' 没有名为 'c_str' 的成员</std::__cxx11::basic_string<char> - cpp: error: 'class boost::optional<std::__cxx11::basic_string<char> >' has no member named 'c_str' &#39;int main(int, int, std::__cxx11::string, std::__cxx11::string)&#39; 只接受零个或两个参数 [-Wmain] - 'int main(int, int, std::__cxx11::string, std::__cxx11::string)' takes only zero or two arguments [-Wmain] 无法转换 'std::__cxx11::string {aka std::__cxx11::basic_string<char> }' 到 'LPCSTR {aka const char*}'</char> - cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'LPCSTR {aka const char*}' 如何修复R“错误:没有有关变量&#39;CXX11&#39;,&#39;CXX11STD&#39;和&#39;CXX11FLAGS&#39;的信息” - How to fix R “ERROR: no information for variable 'CXX11', 'CXX11STD' and 'CXX11FLAGS'” c++ 无法将 'std::string' {aka 'std::__cxx11::basic_string'} 转换为 'std::string (*)[3]' {aka 'std::__cxx11::basic_string (*)[3] '} - c++ cannot convert ‘std::string’ {aka ‘std::__cxx11::basic_string’} to ‘std::string (*)[3]’ {aka ‘std::__cxx11::basic_string (*)[3]’} 错误:无法从“向量”转换“标签” <std::vector<std::__cxx11::basic_string<char> &gt;&gt;' 到 ' 向量<std::__cxx11::basic_string<char> &gt;' </std::__cxx11::basic_string<char></std::vector<std::__cxx11::basic_string<char> - error: could not convert 'tab' from 'vector<std::vector<std::__cxx11::basic_string<char> >>' to 'vector<std::__cxx11::basic_string<char>>' 尝试生成随机字母错误:无法转换 'std::__cxx11::string {aka std::__cxx11::basic_string<char> }' 到 'char' 在分配</char> - Trying to generate a random letter error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'char' in assignment
相关标签
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM