On 2015-02-19 07:29, Daniel Teske wrote: > Qt's container classes and C++11 range based for loop do not mix very well. > Ranged based for uses std::begin(container), which if not overloaded calls > container.begin(), which detaches.
As an aside, the "correct" fix for this IMHO is for range-based for to support a mechanism for marking the RHS 'const', whether or not it otherwise would be so. Worst case, Qt could (should?) implement something like: struct QConstWrapper<ContainerType> { ContainerType::const_iterator begin() const; ContainerType::const_iterator end() const; // remaining "magic" elided }; QConstWrapper<ContainerType> qConst(ContainerType const&); That said, note that range-based for also differs from foreach in that the former operates on the original container, whereas the latter operates on a copy. -- Matthew _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development