[libcxx-commits] [libcxx] [libc++][test] Test SFINAE for `optional`'s operators in C++17 (PR #221643)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 7 07:47:34 PDT 2026
================
@@ -349,6 +326,139 @@ struct ImplicitBool {
constexpr ImplicitBool operator==(ImplicitBool::E1 lhs, ImplicitBool::E2 rhs) { return {lhs.x == rhs.y}; }
+#elif TEST_STD_VER >= 14
+
+template <typename T1, typename T2 = T1, typename = void>
+constexpr bool HasOperatorEqual = false;
+template <typename T1, typename T2>
+constexpr bool HasOperatorEqual<T1, T2, decltype((void)(std::declval<T1&>() == std::declval<T2&>()))> = true;
+
+template <typename T1, typename T2 = T1, typename = void>
+constexpr bool HasOperatorGreaterThan = false;
+template <typename T1, typename T2>
+constexpr bool HasOperatorGreaterThan<T1, T2, decltype((void)(std::declval<T1&>() > std::declval<T2&>()))> = true;
----------------
Zingam wrote:
If I recall correctly the original idea was to have a structure: declare the concepts, then declare type and test it against the concepts, this order looks a bit all over the place.
https://github.com/llvm/llvm-project/pull/221643
More information about the libcxx-commits
mailing list