Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-10-20 14:51:54


Stefan Seefeld wrote:
> another argument is legacy / compatibility. I'v written an XML library
> in C++ that essentially wraps a C library (libxml2 for the insiders),
> and so I'd like to avoid unnecessary string copies when passing data
> around.
> While the inside uses utf-8, I want to make the wrapper API adaptive
> to user-side unicode APIs. Thus the unicode type has become a template
> parameter, and conversion is being done by a trait class.

If the inside uses UTF-8, you should just accept UTF-8. The standard way to
avoid copies is to provide a function/constructor that takes an iterator
range. Users can now pass anything and aren't forced to exclusively choose
one encoding, which becomes a part of the component type and can never be
changed.

To paraphrase, unnecessary parameterization is the root of most evil
nowadays. Parameters are a liability, not an asset.


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