Boost logo

Boost :

From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2007-06-25 13:22:39


The main problem with a policy-based type, such as a string type with
many options (flex_string for example), is that different versions of
the template are different types, and as such are incompatible.

An obvious solution would be a type that can hold any of the template
instantiations, and dispatch the member functions to the appropriate
type through virtual calls, that could eventually use the stack like
boost.variant.

However, this should have quite of a performance penalty, and some of
the advantages of the policies (such as Small String Optimization) would
become either useless (dynamic allocation) or annoying when disabled
(stack allocation).

An alternative would be to simply use typedef to choose the type you
want to use throughout the program, which would somehow give source
compatibility.

How do people feel about types with lots of policies? How could those
issues be addressed, for example in the case of a string type, where
there is quite some demand for policies?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk