此MCVE与gcc 7.3一起编译/运行:
Allocator
模板没有意义,但它不影响施工!
#include <regex>
#include <string>
#include <iostream>
namespace FaF
{
template <typename T>
class Allocator
{
public:
typedef T value_type;
Allocator() throw() {}
template <typename U> Allocator (const Allocator<U>&) throw() {}
~Allocator() throw() {}
T* allocate (std::size_t num, const void* hint = 0)
{
(void) hint; (void) num;
return new ( T );
}
void deallocate (T* p, std::size_t num) { (void) num; (void) p; }
};
using string = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
using smatch = std::match_results<FaF::string::const_iterator, Allocator<FaF::string::const_iterator>>;
}
int main()
{
FaF::smatch results {};
std::cout << "OK\n";
}
哪里
分配器
是我自己的分配器。
我们现在使用gcc 8.2并得到这个错误
FaF::smatch results {};
^--- vector must have the same value as its allocator
当我改变
FaF::smatch
std::smatch
然后使用gcc 8.2编译/运行。
我的问题是:
看看吧
live
-clang 6.0接受带有
也。
编译器标志:
-O3 -std=c++17 -Werror -Wextra -Wold-style-cast -Wall