|
Boost : |
From: Carlo Wood (carlo_at_[hidden])
Date: 2002-09-01 00:13:55
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]>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk