The following snippet doesn't build when using gcc and libc++:
#include <string> void f(const std::string& s) { s.begin(); } #include <vector> void AppendTo(const std::vector<char>& v) { v.begin(); }
The problem is that wrap_iter has a private constructor. It lists vector<> and basic_string<> as friends, but gcc seems to ignore this for vector<> for some reason. Declaring vector before the friend declaration in wrap_iter is enough to work around this problem, so do that. With this patch, I'm able to build chromium/android with libc++. Without it, two translation units fail to build.
As far as I can tell, this is due to a gcc bug, which I filed as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816.
Fixes PR22355.
There's also a friend decl for basic_string in __wrap_iter; why don't we need a fwd declaration for that as well?
(because it's a compiler bug?)