Boost logo

Boost :

From: Carlo Wood (carlo_at_[hidden])
Date: 2002-08-30 09:42:21


On Fri, Aug 30, 2002 at 03:54:03PM -0400, Toon Knapen wrote:
> I would prefer though
> std::string demangle(const std::type_info& i)
> because e.g. it's easier to use it in
> std::cout << demangle( typeid(a) ) << std::endl;

This is not the most general interface and will have
to be a wrapper around the more general one.

Ie

void demangle(std::string& t_o, char const* t_i);

std::string demangle(char const* t_i)
{
  std::string t_o;
  demangle(t_o, t_i);
  return t_o;
}

std::string demangle(std::string const& t_i)
{
  return demangle(t_i.c_str());
}

std::string demangle(std::type_info const& i)
{
  return demangle(i.name());
}

Note these wrappers will not cause extra string copy constructors
to be called, as the standard allows (demands?) to skip that.

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