concepts: Add header for common concepts
Initially, this is just a concept for the presence of an equals
operator.
Change-Id: I2838b589fa22f60489bba6a05ee56909c86c14b9
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/meson.build b/include/meson.build
index 56f9c8e..a31fae5 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -2,6 +2,7 @@
install_headers(
'stdplus/cancel.hpp',
+ 'stdplus/concepts.hpp',
'stdplus/exception.hpp',
'stdplus/flags.hpp',
'stdplus/handle/copyable.hpp',
diff --git a/include/stdplus/concepts.hpp b/include/stdplus/concepts.hpp
new file mode 100644
index 0000000..41373f6
--- /dev/null
+++ b/include/stdplus/concepts.hpp
@@ -0,0 +1,25 @@
+#pragma once
+#include <concepts>
+#include <type_traits>
+
+namespace stdplus
+{
+
+template <typename T, typename U>
+concept WeaklyEqualityComparableWith = requires(
+ const std::remove_reference_t<T>& t, const std::remove_reference_t<U>& u) {
+ {
+ t == u
+ } -> std::convertible_to<bool>;
+ {
+ t != u
+ } -> std::convertible_to<bool>;
+ {
+ u == t
+ } -> std::convertible_to<bool>;
+ {
+ u != t
+ } -> std::convertible_to<bool>;
+ };
+
+}