24 template<auto method_ptr_t>
25 struct double_dispatch_class_method_ptr_traits;
27 template<
class class_t,
class return_t, return_t (
class_t::*method_ptr_t)(const
class_t&) const>
28 struct double_dispatch_class_method_ptr_traits<method_ptr_t>
30 using class_type = class_t;
31 using return_type = return_t;
75 template<auto method_ptr_t>
76 requires is_specialization_exist_v<double_dispatch_class_method_ptr_traits<method_ptr_t>>
77 class double_dispatch_matrix
81 using class_method_ptr_traits_type = double_dispatch_class_method_ptr_traits<method_ptr_t>;
84 using base_type =
typename class_method_ptr_traits_type::class_type;
85 using return_type =
typename class_method_ptr_traits_type::return_type;
86 using function_type = std::function<return_type(
const base_type& first,
const base_type& second)>;
88 static_assert(std::derived_from<base_type, rtti_pure_base>);
98 template<
class first_derived_t,
class second_derived_t>
100 std::is_base_of_v<
typename double_dispatch_matrix<method_ptr_t>::base_type, first_derived_t>
101 && std::is_base_of_v<
typename double_dispatch_matrix<method_ptr_t>::base_type, second_derived_t>)
102 void register_function(
103 std::function<return_type(const first_derived_t&, const second_derived_t&)> function) noexcept;
111 std::optional<return_type> invoke(const base_type& first, const base_type& second);
118 bool check_matrix_completeness() const noexcept;
127 function_type& get_function(class_id first, class_id second) noexcept;
130 std::unordered_map<class_id, std::unordered_map<class_id, function_type>> m_MatrixFunctions;
135 #include <qx/patterns/double_dispatch_matrix.inl>
RTTI system based on polymorphism.
#define QX_SINGLETON(T)
Simple Meyer's singleton.