What is the reason for having methods such as void QList::push_back ( const T & value )
in QT when it is doing the same thing as append()
What kind of compatibly does the documentation means. Can any one please elaborate this
Following is the statement from official documentation of QT
"This function is provided for STL compatibility. It is equivalent to append(value)"
This is typically used so that method templates that expect standard containers as their template parameters can be used with a QList
as well, since they will share the same methods.
For example:
template<typename Container>
void move_elements(Container &to, const std::vector<int> &from)
{
for (auto elem : from)
to.push_back(elem);
}
Could be called with both a std::list<int>
and a QList<int>
as the to
parameter.