Here is a toy C++ file named cbegin.cpp
:
#include <iostream>
#include <vector>
int main()
{
std::vector<std::string> toto;
auto first = toto.cbegin();
return 0;
}
I want to compile it with this command:
clang -x c++ -arch i386 -std=c++11 -stdlib=libstdc++ -lstdc++ cbegin.cpp -o cbegin
But I get this error:
cbegin.cpp:7:20: error: no member named 'cbegin' in 'std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >'
auto first = toto.cbegin();
If I use libc++
, it works well:
clang -x c++ -arch i386 -std=c++11 -stdlib=libc++ -lstdc++ cbegin.cpp -o cbegin
Why libstdc++
doesn't recognize std::vector::cbegin
? I can't move to libc++
in my project because I have external dependencies compiled with libstdc++
.