|
Boost : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-08-30 10:48:12
On Friday 30 August 2002 11:12 am, Carlo Wood wrote:
> - The most general interface is
>
> template<typename Allocator>
> void demangle_type(
> std::basic_string<char, std::char_traits<char>, Allocator>& output,
> char const* input,
> size_t length = 0);
>
> Where length is the maximum number of character read from
> the input, or 0 when input needs to be read till a terminating '\0'.
>
> Anyone with strong objections or good arguments to
> use another 'inner' interface?
Well, if we're really worried about avoiding string copying altogether, we'll
want to generalize away the string entirely (so we could write directly to a
stream or into a non-string buffer, for instance). The interface could be
iterator-based, e.g.,
template<typename InputIterator, typename Allocator, typename OutputIterator>
OutputIterator demangle_type(InputIterator first, InputIterator last,
const Allocator& allocator, OutputIterator out);
This gets rid of some of the special-case behavior (e.g., input is
null-terminated when length == 0), places all of the allocation for the user
solidly in the user's domain (the OutputIterator handles it), and allows a
different allocator for internal memory (not sure that this is necessary...).
You won't even need to #include <string> :)
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk