3 ms·
This is quite unfair. Boost.container::vector implements the full standard vector interface (that's already a large interface), plus quite a few non-standard e
by gpderetta 6y ago
This is quite unfair.
Boost.container::vector implements the full standard vector interface (that's already a large interface), plus quite a few non-standard extensions (significantly it has built-in support for default initialization).
Boost.container also has support for stateful allocators and custom pointer types so that it can be used, for example, on shared memory (in fact boost container was originally a sub-library of boost.interprocess). That alone will increase the complexity significantly.
It also I believe still support pre-c++11 (and substandard post c++11) compilers, so there is a lot of compiler workarounds and emulation of c++11 features.
Also, being a template, the whole implementation is just in the _header_.
- jstimpfle 6y agoAnd you don't notice how you're only making my point? As for being a template, that doesn't preclude from having most of the implementation in a .cpp file. In fact that's highly desirable (separate compilation).
- gpderetta 6y agoMy point is that you would use boost.container if you need its additional features otherwise just use the equivalent standard containers. The complexity is there for a reason. A separate .cpp would require explicit instantiation. I do not see how that would work for a third party library that has to work for any T. Normally you can at least abstract away the memory management code, but in the case of boost container the use of custom allocators is expected, so you can't even do that.
- kllrnohj 6y agoIt's desirable for complication speed, but not for performance. The blessing & curse of templates is that while you pay for them in compilation speed, you're also getting every scrap of localized optimizations possible without needing to run a much slower, and less capable, LTO pass. There isn't a "strictly better" here, it's a trade-off. If you want a split implementation, make one. That's the beauty of C++ - there's nothing special the standard library can do that you can't. Android, for example, has a split implementation: https://cs.android.com/android/platform/superproject/+/master:system/core/libutils/include/utils/Vector.h https://cs.android.com/android/platform/superproject/+/maste... (I wouldn't use it, though, it's pretty outdated & shitty, but you can still do what you're talking about).
- deleted 6y ago[deleted]