[Development] Proposal: Deprecating platforms in Qt 5.6 that don't support lambda

Matthew Woehlke mw_triad at users.sourceforge.net
Thu Feb 19 18:07:04 CET 2015

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.


More information about the Development mailing list