The boolean-testable requirements don't require the type to be copyable,
so we need to convert to bool before it might need to be copied.
libstdc++-v3/ChangeLog:
PR libstdc++/119545
* include/std/tuple (operator==): Convert comparison results to
bool.
* testsuite/20_util/tuple/comparison_operators/119545.cc: New
test.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
{
return [&]<size_t... _Inds>(index_sequence<_Inds...>) {
// Fold == over the tuples until non-equal elements are found.
- return ((std::get<_Inds>(__t) == std::get<_Inds>(__u)) && ...);
+ return (bool(std::get<_Inds>(__t) == std::get<_Inds>(__u)) && ...);
}(index_sequence_for<_Tps...>{});
}
--- /dev/null
+// { dg-do compile { target c++11 } }
+// Bug libstdc++/119545
+// tuple::operator==()'s help lambda does not specify return type as bool
+
+#include <tuple>
+
+void
+test_pr119545()
+{
+ struct Bool {
+ Bool() = default;
+ Bool(const Bool&) = delete;
+ operator bool() const { return true; }
+ };
+
+ static Bool b;
+
+ struct Object {
+ const Bool& operator==(const Object&) const { return b; }
+ };
+
+ std::tuple<Object> t;
+ (void) (t == t);
+}