From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2004-03-26 17:10:58
> This is probably the best characterization of the traits/policy
> distinction I've heard. I don't agree entirely about basic_string,
> however; I think that the comparison functions such as
> char_traits::compare have to be made available through template
> parameters, otherwise you wouldn't be able to reuse basic_string if
> you want strings with different comparison criteria.
This is a problem with char_traits design - it mixes things that belong to
traits and to policies.
> Most of the stuff
> in char_traits, such as the typedefs, copy, move, to_int_type, eof
> could go in a genuine traits template, so that basic_string would look
> like this:
> template<typename Ch, typename Comp = std::char_compare<Ch> >
> class basic_string;
We could do something like this. But as you have says yourself (and Herb
Sutter in the book ) in majority of the cases it does not worse the trouble.
In practice you couldn't change string class globally in whole application
to use different comparison. In consequence you will pay with a lot of
conversions. Though even what you wrote above is better than what we have
> This wouldn't make a practical difference for strings, but it might
> mean that iostreams wouldn't need traits parameters at all -- I
> haven't verified this -- which would be a huge advantage.
And for many other classes that are trying to support Unicode.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk