Skip to Content
Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions
book

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

by Herb Sutter
November 1999
Intermediate to advanced
240 pages
5h 22m
English
Addison-Wesley Professional
Content preview from Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

Chapter 4. Maximally Reusable Generic Containers—Part 1

Difficulty: 8

How flexible can you make this simple container class? Hint: You'll learn more than a little about member templates along the way.

How can you best implement copy construction and copy assignment for the following fixed-length vector class? How can you provide maximum usability for construction and assignment? Hint: Think about the kinds of things that client code might want to do.

 template<typename T, size_t size> class fixed_vector { public: typedef T* iterator; typedef const T* const_iterator; iterator begin() { return v_; } iterator end() { return v_+size; } const_iterator begin() const { return v_; } const_iterator end() const { return v_+size; } private: T v_[size]; };  ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions

Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions

Herb Sutter

Publisher Resources

ISBN: 0201615622Purchase book