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

meta: relaxed checks on conversion functions

Michele Caini 4 лет назад
Родитель
Сommit
5a0a682d35
1 измененных файлов с 2 добавлено и 8 удалено
  1. 2 8
      src/entt/meta/factory.hpp

+ 2 - 8
src/entt/meta/factory.hpp

@@ -269,12 +269,9 @@ public:
      */
     template<auto Candidate>
     auto conv() ENTT_NOEXCEPT {
-        using conv_type = std::remove_const_t<std::remove_reference_t<std::invoke_result_t<decltype(Candidate), Type &>>>;
-        static_assert(!std::is_same_v<Type, conv_type> && std::is_convertible_v<Type, conv_type>, "Could not convert to the required type");
-
         static internal::meta_conv_node node{
             nullptr,
-            internal::meta_node<conv_type>::resolve(),
+            internal::meta_node<std::remove_const_t<std::remove_reference_t<std::invoke_result_t<decltype(Candidate), Type &>>>>::resolve(),
             [](const meta_any &instance) -> meta_any {
                 return forward_as_meta(std::invoke(Candidate, *static_cast<const Type *>(instance.data())));
             }
@@ -296,12 +293,9 @@ public:
      */
     template<typename To>
     auto conv() ENTT_NOEXCEPT {
-        using conv_type = std::remove_const_t<std::remove_reference_t<To>>;
-        static_assert(!std::is_same_v<Type, conv_type> && std::is_convertible_v<Type, conv_type>, "Could not convert to the required type");
-
         static internal::meta_conv_node node{
             nullptr,
-            internal::meta_node<conv_type>::resolve(),
+            internal::meta_node<std::remove_const_t<std::remove_reference_t<To>>>::resolve(),
             [](const meta_any &instance) -> meta_any { return forward_as_meta(static_cast<To>(*static_cast<const Type *>(instance.data()))); }
             // tricks clang-format
         };