Argh. Ich sollte meine Beispiele ausprobieren, bevor ich sie poste. Bitte vielmals um Entschuldigung, ich habe zu schnell auf den allgemeinen Fall geschlossen. Es handelt sich definitiv um einen Bug: der Code
Code: Alles auswählen
#include <vector>
#include <iostream>
#include <fstream>
int main()
{
std::vector<bool> b(10);
std::ifstream ifs("test");
ifs>>b[1];
}
spuckt mit Fehlern um sich, macht man aus dem <bool> ein <char> o.a., geht es. Die Ausgabe per ofstream geht auch.
g++ Version: wie Deine
Fehler:
Code: Alles auswählen
main.cpp: In function 'int main()':
main.cpp:9: error: no match for 'operator>>' in 'ifs >> b. std::vector<bool, _Alloc>::operator[] [with _Alloc = std::allocator<bool>](1u)'
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:131: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_Char
T, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:134: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _
Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:137: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::
ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:169: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = ch
ar, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:172: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT
= char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:175: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [wi
th _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:178: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = cha
r, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:181: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _Ch
arT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:184: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT
= char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:187: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [wit
h _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:191: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _C
harT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:194: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&)
[with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:198: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = c
har, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:201: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT =
char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:204: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _Cha
rT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:207: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = c
har, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:230: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_streambuf<_Ch
arT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:734: note: std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*) [with _T
raits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:729: note: std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*) [with
_Traits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:693: note: std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&) [with _T
raits = std::char_traits<char>]
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/istream:688: note: std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&) [with
_Traits = std::char_traits<char>]
Das Problem ist der Parser. Der ist nicht fuzzy genug.
--Klaus Knopper