明確にするために、文字列クラスのグローバルな getline() 関数について言及しています。
私がやりたいことは、次のようなものを持つことです:
int main()
{
wifstream in(L"textfile.txt");
someFunc(in);
return 0;
}
void someFunc(const wistream& read)
{
wstring buff;
while(getline(read, buff))
{
//do some processing here
}
}
しかし、私は得ています:
Error 2 error C2664: 'std::getline' : cannot convert parameter 1 from 'const std::wistream' to 'std::basic_istream<_Elem,_Traits> &'
それを修正するには、const wistream& read から const を削除する必要があります。なぜこれが起こっているのか理解していますが、変換せずに代わりに wistream を受け入れるように getline() を構成することは可能ですか、それとも無視して const を削除する必要がありますか?