Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-04-01 17:46:06

David Abrahams writes:

>I think your definitions are mostly on target, but I think where you
>go wrong is that traits/policies has less to do with how a template
>is defined than how it's used.

To me a traits class provides information to a template class that gives
(possibly platform or type dependant) information. For example, the decimal
point character (100.00 or 100,00?) would be in a traits class (I know this
is in a locale, but this is an example). Another example would be a format
string to use as a separator between items in a list, depending on whether a
character, string, wide character, wide string, etc are used.

A policy class provides functional, i.e. behavioural, information. Examples
include string comparison, pointer validation (for smart pointers) and error
handling (e.g. smart pointers and how to handle InvalidPointer - nothing,
throw std::exception, assert failure, etc.).


Express yourself with cool new emoticons

Boost list run by bdawes at, gregod at, cpdaniel at, john at