Re: [Re: [libxml++] UTF8 support]



Murray Cumming <murrayc usa net> writes:

> Ole Laursen <olau hardworking dk> wrote:
> > Perhaps this idea is better. If there is an implicit
> > conversion to char*, it will interface nicely with both std::string
> > and Glib::ustring.
> 
> I asumme you mean "const char*".
>
> Implicit conversions to const char* lead to implicitly orphaned pointers. I
> believe that's why std::string has no implcit conversion to const char*.
> Glib::ustring tries to mimick the std::string API as much as possible, as we
> asssume that the designers of std::string know what they are doing.

I think I can see why:

  // convenience function
  const char *get_data()
  {
    // ...
    c = xmlpp::get_some_data();  // implicit conversion
  }

  const char *c = get_data(c);

  // c now points to deleted data

One could easily write such code.

-- 
Ole Laursen
http://www.cs.auc.dk/~olau/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]