疑問点の整理

arbitrary_positional_facade::close()とBase64のアダプタを作成してみて、一応動いているのですが、曖昧な点がいくつか見つかったので保留にしました。
以下、TODOリスト兼まとめです。判明次第埋めていく予定。

アダプタやフィルタのclose()で元のデバイスをclose()すべきか()

  • Boostのフィルタはclose()を呼んでいる呼んでいない
  • ClosableでないフィルタとClosableなデバイスの組み合わせでclose()を呼ぶと、デバイスはclose()されない(flushされるだけ。多分バグ)フィルタがclose()を呼ばないので問題なし。

今のところの結論: フィルタはclose()すべきでない。アダプタはclose()すべき。

closeの意味

  • バイスを実際に閉じることとフッタ出力の意味でごっちゃになっているような
  • デストラクタがclose()を呼ぶ必要はない
  • ready to begin processing a new character sequenceって?

User's Guideには、

A Filter or Device which receives notifications immediately before a stream is closed.

と書いてあって、実際にデバイスを閉じるわけではないように読める。

一方、http://lists.boost.org/Archives/boost/2004/09/71244.php では、

F. Filters and resources must free all associated resources (in the usual sense) either:
1. When the stored copy is destroyed, or
2. If the filter or resource type models Closable and i/o has commenced, when the function boost::io::close() is called.

全てのリソースを解放すべしと書いてある。(Review時の発言のため古い情報の可能性あり)

今のところの結論: バッファに残ったデータを処理してデバイスを閉じる。デストラクタはバッファに残ったデータを捨てるかもしれない。(正常終了時は明示的にclose()を呼ぶべき。boost::iostreams::copy()はclose()を呼んでくれる。)

バイス/フィルタのコピーの意味

  • CopyConstructibleであっても、Assignableである必要はない
  • コピー元のデバイス/フィルタはどうなる?
  • Boost MLで議論があったはず(要確認→見つからない、、、)

↓上記と同じメールでの記述。 

B. It is unspecified whether filters and resources which are copy constructible have deep copy semantics.
D. The library may make an arbitrary number of copies (usually just one) of a filter or resource, but only one is stored, and no copies are made after i/o begins

今のところの結論: 最後のコピーだけ有効。I/Oが始まったらコピーしない。I/O後にメンバを読み出したい場合は、boost::refを使う。