First of all, you should probably pass a reference to the stream, because otherwise you'll have to write (*out)<<
to make the insertion operator work correctly (it works on streams, not on pointer to streams).
しかし、もっと重要なのは、 std :: iOS
はストリームの基本クラスの1つ、つまり、テンプレートパラメータに依存しないIOクラスのメンバーを含むものです。
一般的な出力ストリームを受け取る場合は、 std :: ostream
( char
ベースストリームの場合)または std :: wostream
( wchar_t
ベースのストリームの場合)。ジェネリックにしたい場合は、 char_type
と char_traits
の関数テンプレートを std :: basic_ostreamクラス
しかし、文字型に依存しないコードを書くことはしばしば単純ではなく、必要がない場合は、努力する価値がないかもしれません - いくつかの TCHAR
のような戦略を使うことをお勧めします。
だから、おそらくあなたが望むのは:
F(std::ostream & out)
(入力ストリームの場合はまったく同じですが、 std :: istream
/ std :: wistream
/ std :: basic_istream
)