This question started for me when I had to handled files that could be either compressed or uncompressed and I needed to do so transparently.
If you look online, there may be only one answer to that, and it is on StackOverflow when I answered it. Here is some more context to what the answer does and what’s the problem with Boost::Iostreams.