[Kde-bindings] Duplicate methods for QByteArray::data()

Arno Rehn arno at arnorehn.de
Sat Nov 7 12:36:13 UTC 2009


On Saturday 07 November 2009 00:19:06 Chris Burel wrote:
> 2009/11/6 Ian Monroe <ian.monroe at gmail.com>:
> > On Fri, Nov 6, 2009 at 4:43 PM, Chris Burel <chrisburel at gmail.com> wrote:
> >>> There are some use cases, especially in QtDBus, where
> >>> you need the 'const' version of a method. Depending on whether the
> >>> method is const or not the returned value differs.
> >>
> >> Really?  The only thing that looks different is the call to detach().
> >> And if you really want the const data, couldn't you use constData?
> >> inline char *QByteArray::data()
> >> { detach(); return d->data; }
> >> inline const char *QByteArray::data() const
> >> { return d->data; }
> >> inline const char *QByteArray::constData() const
> >> { return d->data; }
> >
> > Arno was saying that this distinction was needed for methods in
> > QtDbus, not that it was required for QByteArray.
> >
> > Ian
> 
> Ah, ok, that makes a lot more sense.  How does the ambiguous method
> resolution work for those cases?  And can you guys point me to some
> specific examples so that I can make test cases?
QtRuby and Qyoto still default to the non-const version and don't have a way 
to use the const one. The lisp bindings now have a public field that can be 
set and depending on the value you can call the const or non-const method. 
Tobias Rautenkranz is the developer of these bindings, he probably has more 
information on that.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list