5 ms·
And 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
by jstimpfle 6y ago
And 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]