Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
I wonder if there is a way to get immutable list from regular QList. A fail-safe list is better but I would appreciate any suggestions.
Thanks in advance)
I wonder if there is a way to get immutable list from regular QList.
Is that what you're after?
QList<int> mutableList; const QList<int> & immutableList = mutableList;
A fail-safe list is better
What do you mean by fail-safe list?
Thanks for your reply)
I'd like to provide some clarifications:
By saying "immutable" I meant that after some elements are added to this list, its content cannot be modified - add, remove and insert operations are prohibited or just won't take any effect.
By saying "fails-safe" I meant that whenever such an operation is called on immutable list no application failure will arise and no exception will be thrown.
Both your requirements are met by the const keyword in C++. A const object can't be modified and prevents you from calling non-const functions. What is it that you're trying to achieve?
Thanks for your reply) This is exactly what I needed)