HomePhabricator

[libc++] Fix build failure with _LIBCPP_DEBUG=0 when iterators return values…

Authored by thomasanderson on Apr 15 2019, 10:02 AM.

Description

[libc++] Fix build failure with _LIBCPP_DEBUG=0 when iterators return values instead of references

There are many STL algorithms (such as lexicographical_compare) that compare
values pointed to by iterators like so:

    __comp(*it1, *it2);

When building with _LIBCPP_DEBUG=0, comparators are wrapped in __debug_less
which does some additional validation. But __debug_less::operator() takes
non-const references, so if the type of *it1 is int, not int&, then the build
will fail.

This change adds a const& overload for operator() to fix the build.

Differential Revision: https://reviews.llvm.org/D60592

llvm-svn: 358423