
On 6/29/2013 12:40 PM, Mathias Gaunard wrote:
What should I do if I want to define the operators on my own user-defined type?
Write them. It should be easy. For example, this is all it takes for
ibitstream to support std::bitset:
template
See Rob's response. I assumed ibitstream derived from istream. Is that not the case?
That is not the case. See my reply to Mathias' similar query at http://article.gmane.org/gmane.comp.lib.boost.devel/242607
Does the ibitstream even use similar virtual functions and buffering mechanisms as istream?
Well, it follows std::istringstream and therefore std::istream. As far as possible, ibitstream and bitbuf have the same member functions and semantics as std::istringstream and std::stringbuf.
I suspect writing the value directly to the stream (possibly after byte swapping) would be faster than shifts and bitwise ands and writing it byte per byte.
I agree. However, my main concern was stability through simplicity. There is plenty of room for optimization, which I plan to do. Paul