Re: [Development] RFC: Containers member functions for algorithm

2017-03-27 Thread Eike Ziller
> On Mar 24, 2017, at 10:33 PM, André Pönitz wrote: > > On Fri, Mar 24, 2017 at 04:25:34PM +, Corentin wrote: >> Is std::algo(std::begin(container), std::end(container) ... ) troublesome >> enough that it warrants a wrapper ? > > Yes. > > 1. It is more to read, and more to verify during r

Re: [Development] RFC: Containers member functions for algorithm

2017-03-24 Thread Ch'Gans
On 25 March 2017 at 07:00, Kevin Kofler wrote: > Michael Winkelmann wrote: >> The reason why STL is using free function is because it separates data >> structures (aka containers) and algorithms. >> A bad example what happens if you dont separate can be seen here: >> https://www.imagemagick.org/ap

Re: [Development] RFC: Containers member functions for algorithm

2017-03-24 Thread André Pönitz
On Fri, Mar 24, 2017 at 04:25:34PM +, Corentin wrote: > Is std::algo(std::begin(container), std::end(container) ... ) troublesome > enough that it warrants a wrapper ? Yes. 1. It is more to read, and more to verify during reading, e.g. that bother 'container' are the same. This typic

Re: [Development] RFC: Containers member functions for algorithm

2017-03-24 Thread Kevin Kofler
Michael Winkelmann wrote: > The reason why STL is using free function is because it separates data > structures (aka containers) and algorithms. > A bad example what happens if you dont separate can be seen here: > https://www.imagemagick.org/api/Magick++/Image_8h_source.html > > ...and your data

Re: [Development] RFC: Containers member functions for algorithm

2017-03-24 Thread Corentin
Is std::algo(std::begin(container), std::end(container) ... ) troublesome enough that it warrants a wrapper ? I have a few concerns: * There is a large momentum behind the range proposal, and, if it wont be in the standard before 2-4 years, I would expect the TS to be usable long before that.

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Thiago Macieira
On quinta-feira, 23 de março de 2017 02:36:06 PDT Marc Mutz wrote: > Second, that member functions always get their *this argument passed by > reference. A free function can take the argument by value instead. The example for this is actually in the other thread: QStringView::indexOf(). If you wr

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Thiago Macieira
On quinta-feira, 23 de março de 2017 00:32:14 PDT Olivier Goffart wrote: > Hi everyone, > > I have been wondering if we should enhance Qt container with member > functions to help using some of the standard algorithm. > a peace of code is better than many words. We would be able to do: [cut] I li

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Milian Wolff
On Thursday, March 23, 2017 11:12:31 AM CET Giuseppe D'Angelo wrote: > Il 23/03/2017 10:50, Philippe ha scritto: > > I hardly imagine a "container" api without a "contains()" member. What I > > would call good sense. Qt already has this, std not. > > > > The other member that makes sense, if "inde

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Giuseppe D'Angelo
Il 23/03/2017 10:36, Marc Mutz ha scritto: > Exactly. Bring back qSort(Container &), calling std::sort(std::begin(c), > std::end(c)). But leave the container interface alone. This could be done "right now" if we add them in a separate namespace. Whether changing qSort itself -- back in the day I

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Viktor Engelmann
I agree, but Marc actually just said that creator could suggest functions with signature f(T) when one presses . after an object o of type T. That's not the same as allowing the syntax o.f() to call f(o). On 23.03.2017 11:51, Konrad Rosenbaum wrote: > On Thursday, March 23, 2017 10:36:06 Marc Mut

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Konrad Rosenbaum
On Thursday, March 23, 2017 10:36:06 Marc Mutz wrote: > There're > proposals floating around for years to make o.f() fall back to f(o) for std > C++. Those are a lot more pain than you'd think! This construct already exists in C# (static extension classes/methods) and it is causing major headache

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Michael Winkelmann
The reason why STL is using free function is because it separates data structures (aka containers) and algorithms. A bad example what happens if you dont separate can be seen here: https://www.imagemagick.org/api/Magick++/Image_8h_source.html ...and your data structure will be bloated with member

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Giuseppe D'Angelo
Il 23/03/2017 10:50, Philippe ha scritto: > I hardly imagine a "container" api without a "contains()" member. What I > would call good sense. Qt already has this, std not. > > The other member that makes sense, if "indexOf()"... Qt already has this. Bikeshedding: this implies that your container

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Marc Mutz
On 2017-03-23 11:01, Ville Voutilainen wrote: On 23 March 2017 at 11:36, Marc Mutz wrote: That said, there's a reason why there's no std::sort(Container &). It's because you need Concepts to disambiguate the various overloads. Well, that and because Eric Niebler doesn't manage to limit the sco

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Ville Voutilainen
On 23 March 2017 at 11:36, Marc Mutz wrote: > That said, there's a reason why there's no std::sort(Container &). It's > because you need Concepts to disambiguate the various overloads. Well, that > and because Eric Niebler doesn't manage to limit the scope of his range > proposals. The TS proposa

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Philippe
I hardly imagine a "container" api without a "contains()" member. What I would call good sense. Qt already has this, std not. The other member that makes sense, if "indexOf()"... Qt already has this. For the rest, free functions provide more flexibility. >> I realize that QtCreator already has h

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Marc Mutz
On Thursday 23 March 2017 09:27:53 Eike Ziller wrote: > I do not think that these belong into the API of the containers though, or > at least if (some of) this API gets into the containers itself, the > implementation should just call generic functions. There is no reason why > the convenience shou

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Eike Ziller
> On Mar 23, 2017, at 8:32 AM, Olivier Goffart wrote: > > Hi everyone, > > I have been wondering if we should enhance Qt container with member functions > to help using some of the standard algorithm. > a peace of code is better than many words. We would be able to do: > > myList.sort(); > //

Re: [Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Simon Hausmann
Hi, I love this idea and how it goes into the direction of making life easier (more convenient) for developers. Simon > On 23 Mar 2017, at 08:32, Olivier Goffart wrote: > > Hi everyone, > > I have been wondering if we should enhance Qt container with member functions > to help using some of

[Development] RFC: Containers member functions for algorithm

2017-03-23 Thread Olivier Goffart
Hi everyone, I have been wondering if we should enhance Qt container with member functions to help using some of the standard algorithm. a peace of code is better than many words. We would be able to do: myList.sort(); //or myList.sort([](auto &a, auto &b){ return a.member < b.member; }); if (