2 ms·
A customizable C++ framework
- jzwinck 11y agoThat's not a framework but a function being customized. Calling everything a framework is smelly.
- humanrebar 11y agoFair point, but actual C++ frameworks would benefit from the ideas in this post. Almost all of them provide a list of ICustomizationPoint interfaces to derive from. That approach complicates client code more than the framework authors probably appreciate.
- maxlybbert 11y agoI guess we've been using different frameworks. It's certainly true that the OO-frameworks provide interfaces to derive from. But others have templates to work with. In fact, the standard library does both (e.g., customizing streams via do_get() and do_put(); and providing new iterator types via std::iterator<>).
- apaprocki 11y agoJust as a counter-example, at Bloomberg the way we can measure the bytes any memory-allocating class consumes is by externally passing in a "counting" polymorphic allocator instead of just letting the class fall through to the default allocator. With polymorphic allocators, the type of the object does not change, so it is much easier to do than to try to retrofit STL allocators into the code to achieve the same thing. This of course requires buying into the idea of polymorphic allocators as our STL implements. Lakos et al are pushing this in the committee to become standard. See: https://bloomberg.github.io/bde/group__bdlma__countingallocator.html https://bloomberg.github.io/bde/group__bdlma__countingalloca... If your code previously did (`bsl` is our `std`): bsl::vector<bsl::string> v; v.push_back(...); It simply changes to: bdlma::CountingAllocator ca("Specific vector in my app"); bsl::vector<bsl::string> v(&ca); v.push_back(...); ca.print(bsl::cout); // print memory usage