Comments (5)
I think it's hard-coded because much of the C compression API uses "char" so making it generic would cause lots of other issues.
Also this isn't just bzip2, isn't it? zlib is the same as far as I can tell.
This might be a kind of intentional design choice...
from iostreams.
Sure, in the same way that any wrapper around a C API has hard-coded types. But surely this can be done in such a way that basic_bzip2_compressor<std::allocator<uint8_t>>::char_type
returns the correct thing?
from iostreams.
Note: I am not speaking with any particular authority and certainly not for the boost project.
Maybe I misunderstand, but I think it returns exactly the right thing: The bzip2 compressor always operates on "char" streams. Changing the allocator does not change the stream type.
Reading the code I suspect the easier way to make your example work would be to have some wrapper that just adds a couple of casts around the function calls. But that is rather ugly, and possibly not strictly safe to actually do in all cases/environments?
Certainly not for any type other than uint8_t, so not sure the result will be any less of a mess than just using a "char" filtering stream and do any casts necessary on the input and output side.
from iostreams.
If that's the case what is the point of having a polymorphic basic_bzip2_compressor
in the first place?
I mean, we could have all C++ API just take void *
everywhere and expect the user to cast everywhere, but that makes for a pretty poor API. This holds in this case, too.
from iostreams.
The polymorphism is to allow replacing the allocator, e.g. to allocate from a fixed memory pool on some embedded device. I.e. HOW the memory is allocated, not which TYPE.
And I don't disagree in principle that it would be nice if it could just accept any kind of type, but I think that's not actually easy to do, nor end up very useful in the end. It looks to me in general the only thing it is meant for when implemented is to support both char and wchar_t
from iostreams.
Related Issues (20)
- [Feature request] Request the ability to `sync` single component of chain
- No const overloads for getting the underlying device of boost::iostream::stream
- Using Boost.Iostreams and Bzip2 with link-time optimization can lead to a segmentation fault HOT 1
- iostreams\detail\streambuf\indirect_streambuf.hpp(440) : warning C4702: unreachable code HOT 3
- Cannot disable zstd with "bjam -sNO_ZSTD" in boost/1.78.0 HOT 1
- Hang forever when reset boost::iostreams::filtering_ostream with a broken sink device HOT 4
- Double close possible in file_descriptor_impl::close_impl() HOT 4
- BOOST_DELETED_FUNCTION(...); produces 1683 "extra ‘;’ [-Wpedantic]" warnings. HOT 4
- gzip_decompressor() Segmentation fault HOT 1
- Gzip decompressor throws non-gzip_error HOT 12
- `file_descriptor` device leaks fd on Windows when constructed from int fd
- there is no warning number 4231 4660 HOT 2
- Object Lifetimes documentation missing.
- zstd filter: add support for parallel processing HOT 7
- boost::iostreams::stream<boost::iostreams::array> fails for size > 2GB when calling tellp HOT 5
- Incorrect comment about line ending characters
- Documentation format
- BOOST_ASSERT() in gzip.hpp triggers clang warning -Wstring-conversion
- No way to detect the return code of pubsync() during close()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iostreams.