Boost logo

Boost :

From: Carlo Wood (carlo_at_[hidden])
Date: 2002-08-30 10:12:50


On Fri, Aug 30, 2002 at 10:51:21AM -0400, Douglas Gregor wrote:
> I agree fully. Why not keep the user-friendly interface and add an overload
> with an allocator parameter?
>
> template<typename Allocator>
> std::basic_string<char, std::char_traits<char>, Allocator>
> demangle_type(const std::type_info& type, const Allocator& allocator);
>
> // simpler non-template versions use the default allocator
> std::string demangle_type(const std::type_info& type);
>
> // also provide overloads where the first parameter is an std::string or
> // const char*
>
> Doug

I think we're getting there; if I may summarize:

- The 'real' library interface will be a template
  function (a template library), allowing to specify
  the allocator that the library will use.

Q: Does it make sense to allow to specify two allocators?
   One for internal allocations and one for the string
   that is returned (and passed as input for that matter,
   since it appends to it).

- Then templated wrappers will be added for ALL prototypes
  that people mentioned here, with the restriction that
  the output string always goes up front.

- Then non-templated wrappers will be provided that simply
  use the default allocator.

It is then up to the user to be smart and make sure he
only instantiates the code once (for one allocator)
and only compiles it once (uses a seperate source file
and appropriate dependency rules).

- 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?

I didn't get the remark about C-style overloading :/
Is there a problem with the existance of a prototype that
uses 'char const*' as input?

-- 
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