On 27/11/2018 12.46, Konstantin Shegunov wrote: > On Tue, Nov 27, 2018 at 7:41 PM Matthew Woehlke wrote: >> Is there any reason not to add [createIndex(int, int, void const*)]? > > I'd say the question is rather, is there really a reason to add one?
Well, in my project, I did (add the overload to my own model). Requiring the caller to explicitly cast is annoying, and I don't see any benefit. > Usually the data is contained in a non-const object, presumably in the > model itself, so the pointer isn't ordinarily pointing to an immutable > object. Right. Mostly. Note that in my original example, I was supplying a pointer to a member of my model. Because index() is const, when I take that address, I get a const pointer, even though the member itself isn't const (and it would be okay for me to cast it to non-const when using it in a non-const member). It sounds like Jean-Michaël ran into the exact same problem. > Do you need to enforce the const? In my case, no, and anyway it would be up to the user to DTRT if they pass a pointer to an object that is actually immutable. The point is, the pointer is going to be coerced into a quintptr anyway, so there is no particular reason why we *shouldn't* accept a const pointer as the data... not having that overload just forces the user to explicitly recast the pointer themselves. -- Matthew _______________________________________________ Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
