May 2017
Intermediate to advanced
590 pages
17h 18m
English
The reader is expected to be familiar with smart pointers and std::string_view, both discussed in previous chapters of this book.
To demonstrate the pimpl idiom in a practical manner, we will consider the following class that we will then refactor following the pimpl pattern. The class represents a control that has properties such as text, size, and visibility. Every time these properties are changed, the control is redrawn (in this mocked implementation, drawing means printing the value of the properties to the console):
class control { std::string text; int width = 0; int height = 0; bool visible = true; void draw() { std::cout << "control " << std::endl << " visible: " << std::boolalpha << visible << std::noboolalpha << ...Read now
Unlock full access