oar*_*ish 5 c++ gcc compiler-errors clang c++11
我有一个包含std::set<const std::string>成员的类,它在 macOS 上的 Clang 10.0.1 中编译得很好,但在 GCC 5.4.0 中却没有。下面的 MRE
#include <set>
#include <string>
class Foo {
std::set<const std::string> bar; ///<--- error ‘const _Tp* __gnu_cxx::new_allocator<_Tp>::address(__gnu_cxx::new_allocator<_Tp>::const_reference) const [with _Tp = const std::__cxx11::basic_string<char>; __gnu_cxx::new_allocator<_Tp>::const_pointer = const std::__cxx11::basic_string<char>*; __gnu_cxx::new_allocator<_Tp>::const_reference = const std::__cxx11::basic_string<char>&]’ cannot be overloaded
public:
Foo() {}
};
int main(int argc, char *argv[]) {
Foo f;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译器调用:
/usr/bin/g++ -std=c++11 test.cpp
Run Code Online (Sandbox Code Playgroud)
相反,如果我使用非常量,string它会起作用。这是过时的标准库版本的问题吗?