Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22079

Why is it impossible to create an std::set in C++? [duplicate]

$
0
0

I have a class with std::set<const std::string> members which compiles fine in Clang 10.0.1 on macOS, but does not with GCC 5.4.0. MRE below

#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 overloadedpublic:  Foo() {}};int main(int argc, char *argv[]) {  Foo f;  return 0;}

Compiler invocation:

/usr/bin/g++ -std=c++11 test.cpp

If instead I use non-const string it works.Is this a problem of an outdated standard library version?


Viewing all articles
Browse latest Browse all 22079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>