[libcxx-commits] [libcxx] WIP - [libc++][functional] P2944R3 (partial): Comparisons for ``reference_wrapper`` (``reference_wrapper`` operators only) (PR #88384)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Apr 28 22:28:15 PDT 2024
================
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <functional>
+
+// class reference_wrapper
+
+// // [refwrap.comparisons], comparisons
+
+// friend constexpr synth-three-way-result<T> operator<=>(reference_wrapper, reference_wrapper); // Since C++26
+// friend constexpr synth-three-way-result<T> operator<=>(reference_wrapper, const T&); // Since C++26
+// friend constexpr synth-three-way-result<T> operator<=>(reference_wrapper, reference_wrapper<const T>); // Since C++26
+
+#include <cassert>
+#include <concepts>
+#include <functional>
+
+#include "test_comparisons.h"
+#include "test_macros.h"
+
+struct NonComparable {};
+
+static_assert(!std::three_way_comparable<NonComparable>);
+
+// Test SFINAE.
+
+template <class _Tp>
+concept BooleanTestableImpl = std::convertible_to<_Tp, bool>;
+
+template <class _Tp>
+concept BooleanTestable = BooleanTestableImpl<_Tp> && requires(_Tp&& __t) {
+ { !std::forward<_Tp>(__t) } -> BooleanTestableImpl;
+};
----------------
H-G-Hristov wrote:
Oops, this is a result of copy & paste, same for the comment below.
Is it allowed to use private functions, concepts, etc in the tests? I guess not. So I copied the implementation here. I would have been preferable to use `__boolean_testable` instead of redefining it.
https://github.com/llvm/llvm-project/pull/88384
More information about the libcxx-commits
mailing list