【发布时间】:2017-01-17 01:17:53
【问题描述】:
假设我有以下代码:
class.h
#ifndef CLASS_H
#define CLASS_H
class Class
{
private:
std::regex* regex;
};
#endif
class.cpp
#include <regex>
#include "class.h"
// ...
编译它会导致以下错误:
error: "regex" in namespace "std" does not name a type
std::regex* regex;
^~~~~
但是,我能够以任何其他方式使用 std::regex 库吗? 在 GCC 6.1.1 上运行。还尝试使用 -std=C++11 标志显式编译。
【问题讨论】:
-
#include <regex>inclass.h。 -
@PeteBecker
basic_regex是类模板,regex不是。 -
@songyuanyao 我不敢相信我错过了
标签: c++ regex c++11 g++ libstdc++