From e943c7b95091ddc612c385218937e6043a23b37b Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 12 Feb 2001 14:20:58 +0000 Subject: [PATCH] add fixes from Peter Dimov and Kevlin Henney. [SVN r9158] --- more/generic_programming.html | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/more/generic_programming.html b/more/generic_programming.html index e6d59ef449..88fe04bf20 100644 --- a/more/generic_programming.html +++ b/more/generic_programming.html @@ -33,8 +33,9 @@

Traits

-

A traits class provides a way of associating information with another - type. For example, the class template A traits class provides a way of associating information with a + compile-time entity (a type, integral constant, or address). For example, + the class template std::iterator_traits<T> looks something like this: @@ -61,7 +62,7 @@ struct iterator_traits { are specified for a particular type by (partially) specializing the traits template. -

For an in-depth description of std::type_traits, see For an in-depth description of std::iterator_traits, see this page provided by SGI. Another very different expression of the traits idiom in the standard is std::numeric_limits<T> which provides constants @@ -231,12 +232,14 @@ void append_sequence(Container& c, Iterator start, Iterator finish)

Policies Classes

-

Policies classes are a simple idea we first saw described by Andrei Alexandrescu, but which we - snapped up and quickly applied in the Iterator Adaptors library. A - policies class is a template parameter used to transmit behaviors. A - detailed description by Andrei is available in A policies class is a template parameter used to transmit + behaviors. An example from the standard library is std::, + which supplies memory management behaviors to standard containers. + +

Policies classes have been explored in detail by Andrei Alexandrescu in this paper. He writes: @@ -257,7 +260,12 @@ void append_sequence(Container& c, Iterator start, Iterator finish) from their granularity and orthogonality. Boost has probably diluted the distinction in the Iterator Adaptors library, where we transmit all of an adapted iterator's - behavior in a single policies class. + behavior in a single policies class. There is precedent for this, however: + std::char_traits, + despite its name, acts as a policies class that determines the behaviors of + std::basic_string.

Adaptors