Chapter 5. Maximally Reusable Generic Containers—Part 2
Difficulty: 6
Historical note: The example used in this Item is adapted from one presented by Kevlin Henney and later analyzed by Jon Jagger in issues 12 and 20 of the British C++ magazine Overload. (British readers beware: The answer to this Item goes well beyond that presented in Overload #20. In fact, the efficiency optimization presented there won't work in the solution to this problem.)
What is the following solution doing, and why? Explain each constructor and operator. Does this design or code have any flaws?
template<typename T, size_t size> class fixed_vector { public: typedef T* iterator; typedef const T* const_iterator; fixed_vector() { } template<typename O, size_t osize> fixed_vector( ...
Get Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.