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 final :
public singleton<double_dispatch_matrix<method_ptr_t>>
79 using class_method_ptr_traits_type = double_dispatch_class_method_ptr_traits<method_ptr_t>;
82 using base_type =
typename class_method_ptr_traits_type::class_type;
83 using return_type =
typename class_method_ptr_traits_type::return_type;
84 using function_type = std::function<return_type(
const base_type& first,
const base_type& second)>;
86 static_assert(std::derived_from<base_type, rtti_pure_base>);
96 template<
class first_derived_t,
class second_derived_t>
98 std::is_base_of_v<
typename double_dispatch_matrix<method_ptr_t>::base_type, first_derived_t>
99 && std::is_base_of_v<
typename double_dispatch_matrix<method_ptr_t>::base_type, second_derived_t>)
100 void register_function(
101 std::function<return_type(const first_derived_t&, const second_derived_t&)> function) noexcept;
109 std::optional<return_type> invoke(const base_type& first, const base_type& second);
116 bool check_matrix_completeness() const noexcept;
125 function_type& get_function(class_id first, class_id second) noexcept;
128 std::unordered_map<class_id, std::unordered_map<class_id, function_type>> m_MatrixFunctions;
133 #include <qx/patterns/double_dispatch_matrix.inl>
Inherit the necessary singleton class from this.
requires(same_variadic_args_v< args_t... >) const expr auto coalesce(args_t &&... args)
Coalesce function, C# a ?? b analogue.
RTTI system based on polymorphism.