[Interest] QT API wrapper around std:: containers?

André Somers andre at familiesomers.nl
Fri Jan 30 09:14:39 CET 2015


Felix morack schreef op 29-1-2015 om 21:05:
> Hi,
>
> In light of the size limitations of Qt containers, a collegue 
> suggested writing an API wrapper around a std:: container. His idea 
> was to template-derive from a std::vector or std::map and implement 
> the Qt API as a wrapper around the std:: API.
>
>
> Has this been attempted before?
>
I think you'll run into problems pretty quickly, if you want to keep Qt 
API available. How, for instance, are you going to wrap the int 
indexOf(const T& value, int from) function? What will you return in case 
the value is not found?

The look of much stl code hurts my eyes with all these underscores, 
namespaces and other unneeded items, but technically a lot of that code 
is very well designed. Qt containers support much of the stl API, so you 
can move towards using STL equivalents gradualy already. Just use stl 
algoritms to find items, and you soon won't be needing your indexOf 
function anymore. At that point, you can just replace your Qt container 
with an SQL equivalent.

And indeed: if you really need 2^31 elements in your containers, you 
probably need a different container than a Qt provided one...

André



More information about the Interest mailing list