|
@@ -27,8 +27,8 @@ template<typename Ret, typename... Args>
|
|
|
auto to_function_pointer(Ret(*)(Args...)) -> Ret(*)(Args...);
|
|
auto to_function_pointer(Ret(*)(Args...)) -> Ret(*)(Args...);
|
|
|
|
|
|
|
|
|
|
|
|
|
-template<typename Ret, typename... Args, typename Type, typename Payload, typename = std::enable_if_t<std::is_convertible_v<const Payload &, const Type &>>>
|
|
|
|
|
-auto to_function_pointer(Ret(*)(Type &, Args...), const Payload &) -> Ret(*)(Args...);
|
|
|
|
|
|
|
+template<typename Ret, typename... Args, typename Type, typename Payload, typename = std::enable_if_t<std::is_convertible_v<const Payload *, const Type *>>>
|
|
|
|
|
+auto to_function_pointer(Ret(*)(Type &, Args...), const Payload *) -> Ret(*)(Args...);
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Ret, typename... Args, typename Type, typename Payload, typename = std::enable_if_t<std::is_convertible_v<const Payload *, const Type *>>>
|
|
template<typename Ret, typename... Args, typename Type, typename Payload, typename = std::enable_if_t<std::is_convertible_v<const Payload *, const Type *>>>
|
|
@@ -36,15 +36,15 @@ auto to_function_pointer(Ret(*)(Type *, Args...), const Payload *) -> Ret(*)(Arg
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Class, typename Ret, typename... Args>
|
|
template<typename Class, typename Ret, typename... Args>
|
|
|
-auto to_function_pointer(Ret(Class:: *)(Args...), const Class &) -> Ret(*)(Args...);
|
|
|
|
|
|
|
+auto to_function_pointer(Ret(Class:: *)(Args...), const Class *) -> Ret(*)(Args...);
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Class, typename Ret, typename... Args>
|
|
template<typename Class, typename Ret, typename... Args>
|
|
|
-auto to_function_pointer(Ret(Class:: *)(Args...) const, const Class &) -> Ret(*)(Args...);
|
|
|
|
|
|
|
+auto to_function_pointer(Ret(Class:: *)(Args...) const, const Class *) -> Ret(*)(Args...);
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Class, typename Type>
|
|
template<typename Class, typename Type>
|
|
|
-auto to_function_pointer(Type Class:: *, const Class &) -> Type(*)();
|
|
|
|
|
|
|
+auto to_function_pointer(Type Class:: *, const Class *) -> Type(*)();
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Type>
|
|
template<typename... Type>
|
|
@@ -171,13 +171,27 @@ public:
|
|
|
* or a free function with payload.
|
|
* or a free function with payload.
|
|
|
* @tparam Candidate Member or free function to connect to the delegate.
|
|
* @tparam Candidate Member or free function to connect to the delegate.
|
|
|
* @tparam Type Type of class or type of payload.
|
|
* @tparam Type Type of class or type of payload.
|
|
|
- * @param value_or_instance A valid object that fits the purpose.
|
|
|
|
|
|
|
+ * @param value_or_instance A valid reference that fits the purpose.
|
|
|
*/
|
|
*/
|
|
|
template<auto Candidate, typename Type>
|
|
template<auto Candidate, typename Type>
|
|
|
- delegate(connect_arg_t<Candidate>, Type &&value_or_instance) ENTT_NOEXCEPT
|
|
|
|
|
|
|
+ delegate(connect_arg_t<Candidate>, Type &value_or_instance) ENTT_NOEXCEPT
|
|
|
: delegate{}
|
|
: delegate{}
|
|
|
{
|
|
{
|
|
|
- connect<Candidate>(std::forward<Type>(value_or_instance));
|
|
|
|
|
|
|
+ connect<Candidate>(value_or_instance);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @brief Constructs a delegate and connects a member for a given instance
|
|
|
|
|
+ * or a free function with payload.
|
|
|
|
|
+ * @tparam Candidate Member or free function to connect to the delegate.
|
|
|
|
|
+ * @tparam Type Type of class or type of payload.
|
|
|
|
|
+ * @param value_or_instance A valid pointer that fits the purpose.
|
|
|
|
|
+ */
|
|
|
|
|
+ template<auto Candidate, typename Type>
|
|
|
|
|
+ delegate(connect_arg_t<Candidate>, Type *value_or_instance) ENTT_NOEXCEPT
|
|
|
|
|
+ : delegate{}
|
|
|
|
|
+ {
|
|
|
|
|
+ connect<Candidate>(value_or_instance);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -203,12 +217,33 @@ public:
|
|
|
*
|
|
*
|
|
|
* @tparam Candidate Member or free function to connect to the delegate.
|
|
* @tparam Candidate Member or free function to connect to the delegate.
|
|
|
* @tparam Type Type of class or type of payload.
|
|
* @tparam Type Type of class or type of payload.
|
|
|
- * @param value_or_instance A valid object that fits the purpose.
|
|
|
|
|
|
|
+ * @param value_or_instance A valid reference that fits the purpose.
|
|
|
*/
|
|
*/
|
|
|
template<auto Candidate, typename Type>
|
|
template<auto Candidate, typename Type>
|
|
|
- void connect(Type &&value_or_instance) ENTT_NOEXCEPT {
|
|
|
|
|
- constexpr auto extent = internal::function_extent_v<internal::to_function_pointer_t<decltype(Candidate), Type>>;
|
|
|
|
|
- connect<Candidate>(std::forward<Type>(std::forward<Type>(value_or_instance)), std::make_index_sequence<extent>{});
|
|
|
|
|
|
|
+ void connect(Type &value_or_instance) ENTT_NOEXCEPT {
|
|
|
|
|
+ constexpr auto extent = internal::function_extent_v<internal::to_function_pointer_t<decltype(Candidate), Type *>>;
|
|
|
|
|
+ connect<Candidate>(value_or_instance, std::make_index_sequence<extent>{});
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @brief Connects a member function for a given instance or a free function
|
|
|
|
|
+ * with payload to a delegate.
|
|
|
|
|
+ *
|
|
|
|
|
+ * The delegate isn't responsible for the connected object or the payload.
|
|
|
|
|
+ * Users must always guarantee that the lifetime of the instance overcomes
|
|
|
|
|
+ * the one of the delegate.<br/>
|
|
|
|
|
+ * When used to connect a free function with payload, its signature must be
|
|
|
|
|
+ * such that the instance is the first argument before the ones used to
|
|
|
|
|
+ * define the delegate itself.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @tparam Candidate Member or free function to connect to the delegate.
|
|
|
|
|
+ * @tparam Type Type of class or type of payload.
|
|
|
|
|
+ * @param value_or_instance A valid pointer that fits the purpose.
|
|
|
|
|
+ */
|
|
|
|
|
+ template<auto Candidate, typename Type>
|
|
|
|
|
+ void connect(Type *value_or_instance) ENTT_NOEXCEPT {
|
|
|
|
|
+ constexpr auto extent = internal::function_extent_v<internal::to_function_pointer_t<decltype(Candidate), Type *>>;
|
|
|
|
|
+ connect<Candidate>(value_or_instance, std::make_index_sequence<extent>{});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -310,8 +345,23 @@ delegate(connect_arg_t<Function>) ENTT_NOEXCEPT
|
|
|
* @tparam Type Type of class or type of payload.
|
|
* @tparam Type Type of class or type of payload.
|
|
|
*/
|
|
*/
|
|
|
template<auto Candidate, typename Type>
|
|
template<auto Candidate, typename Type>
|
|
|
-delegate(connect_arg_t<Candidate>, Type &&value_or_instance) ENTT_NOEXCEPT
|
|
|
|
|
--> delegate<std::remove_pointer_t<internal::to_function_pointer_t<decltype(Candidate), Type>>>;
|
|
|
|
|
|
|
+delegate(connect_arg_t<Candidate>, Type &value_or_instance) ENTT_NOEXCEPT
|
|
|
|
|
+-> delegate<std::remove_pointer_t<internal::to_function_pointer_t<decltype(Candidate), Type *>>>;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @brief Deduction guide.
|
|
|
|
|
+ *
|
|
|
|
|
+ * It allows to deduce the function type of the delegate directly from a member
|
|
|
|
|
+ * or a free function with payload provided to the constructor.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param value_or_instance A valid pointer that fits the purpose.
|
|
|
|
|
+ * @tparam Candidate Member or free function to connect to the delegate.
|
|
|
|
|
+ * @tparam Type Type of class or type of payload.
|
|
|
|
|
+ */
|
|
|
|
|
+template<auto Candidate, typename Type>
|
|
|
|
|
+delegate(connect_arg_t<Candidate>, Type *value_or_instance) ENTT_NOEXCEPT
|
|
|
|
|
+-> delegate<std::remove_pointer_t<internal::to_function_pointer_t<decltype(Candidate), Type *>>>;
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|