Ver Fonte

identity: add is_transparent member type

Michele Caini há 4 anos atrás
pai
commit
fe328f6a75
2 ficheiros alterados com 5 adições e 0 exclusões
  1. 3 0
      src/entt/core/utility.hpp
  2. 2 0
      test/entt/core/utility.cpp

+ 3 - 0
src/entt/core/utility.hpp

@@ -8,6 +8,9 @@ namespace entt {
 
 /*! @brief Identity function object (waiting for C++20). */
 struct identity {
+    /*! @brief Indicates that this is a transparent function object. */
+    using is_transparent = void;
+
     /**
      * @brief Returns its argument unchanged.
      * @tparam Type Type of the argument.

+ 2 - 0
test/entt/core/utility.cpp

@@ -1,5 +1,6 @@
 #include <utility>
 #include <gtest/gtest.h>
+#include <entt/core/type_traits.hpp>
 #include <entt/core/utility.hpp>
 
 struct functions {
@@ -14,6 +15,7 @@ TEST(Utility, Identity) {
     entt::identity identity;
     int value = 42;
 
+    ASSERT_TRUE(entt::is_transparent_v<entt::identity>);
     ASSERT_EQ(identity(value), value);
     ASSERT_EQ(&identity(value), &value);
 }