Boost logo

Boost :

From: David Bergman (davidb_at_[hidden])
Date: 2002-09-01 11:59:31


Passing a memory allocator to a demangler...

Maybe we should enforce this to every library in Boost which could
potentially be used in a memory-tight context ;-)

What is this? I hope someone with more Boost muscles than I raises
his/her voice so we can have tools do what they are supposed to do, and
not being forced to pass allocators around...

And, as someone else pointed out, the only way to protect a
"memory-critical" library is to preallocate memory, changing memory
scheme will not work. So, if a library is expected to be used in
memory-critical situations (or allocate huge chunks of data), it should
(through a static "init" or similar method) allocate a huge chunk of
data for internal management early in the process' life.

/David

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Carlo Wood
Sent: Sunday, September 01, 2002 1:14 AM
To: boost_at_[hidden]
Subject: Re: [boost] Demangler; Getting there...

On Sat, Aug 31, 2002 at 01:59:56PM -0400, Douglas Gregor wrote:
> > 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.

Point taken...
Then I'd really like to go for

namespace boost {

  template <typename InputIterator, typename OutputIterator, typename
Allocator = std::allocator>
    OutputIterator demangle_type(InputIterator first, InputIterator
last, OutputIterator out);

  template <typename InputIterator, typename OutputIterator, typename
Allocator = std::allocator>
    OutputIterator demangle_symbol(InputIterator first, InputIterator
last, OutputIterator out);

}

.. as the primary interface, and then perhaps provide a

std::string demangle_symbol(char const*);
std::string demangle_type(char const*);
std::string demangle_type(std::type_info const&);

or whatever... I don't care actually.
Imho, the user should write whatever wrapper they need/want
and boost should only provide the one interface given above.

Remember that this is not really about providing an "easy to use handy
little tool", but about the fact that there simply is NO good demangler
code anywhere in the world available that can legally be used in all
situations and that it is apparently damn hard to write one. Developers
will be very glad they will *only* have to write a wrapper that deals
with an Allocator and iterators; instead of having implement a complete
demangler (its still 2047 lines of code).

Now I have seen two different opinions:
1) People who want stuff like "std::string demangle_type(std::type_info
const&)" and
2) People who said that providing more than one interface (wrappers)
   as part of boost is interface bloat.

I tend to agree with 2). So what shall we do?
How about I just start with only the main interface? :)

-- 
Carlo Wood <carlo_at_[hidden]>
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost

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