January 2019
Intermediate to advanced
512 pages
14h 5m
English
Perhaps the most obvious drawback of the policy-based design is the way we have to declare the concrete objects—specifically, the long list of policies that must be repeated every time. Judicious use of default parameters helps to simplify the most commonly used cases. For example, let's look at the following long declaration:
SmartPtr<C, DeleteByOperator<T>, MoveNoCopy, WithRelease, NoDebug> p( ..... );
This can be reduced to the following:
SmartPtr<C> p( ..... );
This can be done if the defaults represent the most common case of a movable non-debug pointer that uses operator delete. However, what is the point of adding the policies if we are not going to use them? A well-thought-out order of policy parameters ...