|
Boost : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-08-31 12:59:56
On Saturday 31 August 2002 01:21 pm, Carlo Wood wrote:
> This is still a template library and thus solves nothing.
> But - I like the interface you describe here for passing
> the type of the allocator.
>
> We could do:
>
> namespace boost {
>
> template <typename Allocator>
> struct demangler {
> template <typename InputIterator, typename OutputIterator>
> static OutputIterator type(InputIterator first, InputIterator last,
> OutputIterator out); static OutputIterator symbol(InputIterator first,
> InputIterator last, OutputIterator out);
>
> typedef std::basic_string<char, std::char_traits<char>, Allocator> string;
> };
> }
By creating the demangler class template, you're forcing the user to deal with
the allocator. On the other hand, just making the allocator an optional
parameter to a function template hides it completely from users that don't
need it.
> And the usage then will be:
>
> // Define your own convenient interface:
> std::string demangle_type(std::string const& type_i)
> {
> std::string out;
> boost::demangler<std::allocator>::type(type_i.begin(), type_i.end(),
> out.begin()); return out;
> }
Almost :) out.begin() is past-the-end so you can't dereference it. You'll need
to use an insertion iterator.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk