[Bug libstdc++/78134] New: set::set lower_bound() for transparent comparator returns const_iterator
barry.revzin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Oct 27 16:17:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78134
Bug ID: 78134
Summary: set::set lower_bound() for transparent comparator
returns const_iterator
Product: gcc
Version: 6.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
#include <set>
struct comp {
bool operator()(int i, int j) const {
return i < j;
}
using is_transparent = void;
};
template <class T, class U> struct is_same { static constexpr bool value =
false; };
template <class T> struct is_same<T, T> { static constexpr bool value = true;
};
int main() {
using S = std::set<int, comp>;
S s;
static_assert(is_same<decltype(s.lower_bound('a')), S::iterator>::value,
"!");
}
We're invoking the function template version of lower_bound(), but s is
non-const so the result should be iterator. Instead we're getting
const_iterator. This compiles on clang with libc++.
More information about the Gcc-bugs
mailing list