Просмотр исходного кода

test: shared transparent_equal_to type

Michele Caini 2 лет назад
Родитель
Сommit
0ef43f5d57
1 измененных файлов с 20 добавлено и 0 удалено
  1. 20 0
      test/entt/common/transparent_equal_to.h

+ 20 - 0
test/entt/common/transparent_equal_to.h

@@ -0,0 +1,20 @@
+#ifndef ENTT_COMMON_TRANSPARENT_EQUAL_TO_HPP
+#define ENTT_COMMON_TRANSPARENT_EQUAL_TO_HPP
+
+#include <type_traits>
+
+namespace test {
+
+struct transparent_equal_to {
+    using is_transparent = void;
+
+    template<typename Type, typename Other>
+    constexpr std::enable_if_t<std::is_convertible_v<Other, Type>, bool>
+    operator()(const Type &lhs, const Other &rhs) const {
+        return lhs == static_cast<Type>(rhs);
+    }
+};
+
+} // namespace test
+
+#endif