From c0d7b1953fdece864014812c650b05c1362b2716 Mon Sep 17 00:00:00 2001
From: Dave Abrahams A technique that often goes hand in hand with traits classes is tag
- dispatching, which is a way of using function overloading to dispatch
- based on properties of a type. A good example of this is the
+ Tag dispatching is a way of using function overloading to
+ dispatch based on properties of a type, and is often used hand in
+ hand with traits classes. A good example of this synergy is the
implementation of the std::advance()
function in the C++ Standard Library, which increments an iterator
@@ -307,7 +307,7 @@ namespace std {
Note: The type generator concept has largely been
- superseded by the more-refined notion of a metafunction. See
C++ Template
Metaprogramming for an in-depth discussion of metafunctions. Policy classes have been explored in detail by Andrei Alexandrescu in
- this paper. He writes:Tag Dispatching
- Type Generators
-Policy classes are implementations of punctual design choices. They - are inherited from, or contained within, other classes. They provide - different strategies under the same syntactic interface. A class using - policies is templated having one template parameter for each policy it - uses. This allows the user to select the policies needed.
+In brief, policy-based class design fosters assembling a class with + complex behavior out of many little classes (called policies), each of + which takes care of only one behavioral or structural aspect. As the + name suggests, a policy establishes an interface pertaining to a + specific issue. You can implement policies in various ways as long as + you respect the policy interface.
-The power of policy classes comes from their ability to combine - freely. By combining several policy classes in a template class with - multiple parameters, one achieves combinatorial behaviors with a linear - amount of code.
+Because you can mix and match policies, you can achieve a + combinatorial set of behaviors by using a small core of elementary + components.
Andrei's description of policy classes suggests that their power is @@ -460,15 +460,15 @@ void tweak_all_widgets2(int arg) express or implied warranty, and with no claim as to its suitability for any purpose. + --> + --> + --> + -->