xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
overload.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <functional>
7 
9 namespace xtd {
16  template <typename... args_t>
21  template <typename result_t, typename type_t>
22  constexpr auto operator()(result_t (type_t::*method)(args_t...)) const noexcept -> decltype(method) {return method;}
26  template <typename result_t, typename type_t>
27  static constexpr auto of(result_t (type_t::*method)(args_t...)) noexcept -> decltype(method) {return method;}
28  };
29 
34  template <typename... args_t>
35  struct const_overload {
39  template <typename result_t, typename type_t>
40  constexpr auto operator()(result_t (type_t::*method)(args_t...) const) const noexcept -> decltype(method) {return method;}
44  template <typename result_t, typename type_t>
45  static constexpr auto of(result_t (type_t::*method)(args_t...) const) noexcept -> decltype(method) {return method;}
46  };
47 
52  template <typename... args_t>
53  struct overload : const_overload<args_t...>, non_const_overload<args_t...> {
55  using const_overload<args_t...>::of;
57  using non_const_overload<args_t...>::of;
60 
64  template <typename result_t>
65  constexpr auto operator()(result_t (*method)(args_t...)) const noexcept -> decltype(method) {return method;}
69  template <typename result_t>
70  static constexpr auto of(result_t (*method)(args_t...)) noexcept -> decltype(method) {return method;}
71  };
72 
74  template <typename... args_t>
75  inline const overload<args_t...> overload_;
76 
77  template <typename... args_t>
78  inline const const_overload<args_t...> const_overload_;
79 
80  template <typename... args_t>
81  inline const non_const_overload<args_t...> non_const_overload_;
83 }
84 
91 #define overload_ xtd::overload_
92 
99 #define const_overload_ xtd::const_overload_
100 
107 #define non_const_overload_ xtd::non_const_overload_
constexpr auto operator()(result_t(type_t::*method)(args_t...)) const noexcept -> decltype(method)
Returns a pointer to an overloaded method. The template parameter is the list of the argument types o...
Definition: overload.h:22
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
#define non_const_overload_
Helper keyword that use to determine one of non const overloaded methods.
Definition: overload.h:107
constexpr auto operator()(result_t(*method)(args_t...)) const noexcept -> decltype(method)
Returns a pointer to an overloaded method. The template parameter is the list of the argument types o...
Definition: overload.h:65
static constexpr auto of(result_t(type_t::*method)(args_t...) const) noexcept -> decltype(method)
Returns a pointer to an overloaded method. The template parameter is the list of the argument types o...
Definition: overload.h:45
constexpr auto operator()(result_t(type_t::*method)(args_t...) const) const noexcept -> decltype(method)
Returns a pointer to an overloaded method. The template parameter is the list of the argument types o...
Definition: overload.h:40
Represents class that use to determine one of non const overloaded methods.
Definition: overload.h:17
static constexpr auto of(result_t(*method)(args_t...)) noexcept -> decltype(method)
Returns a pointer to an overloaded method. The template parameter is the list of the argument types o...
Definition: overload.h:70
#define overload_
Helper keyword that use to determine one of const and non const overloaded methods.
Definition: overload.h:91
Represents class that use to determine one of const overloaded methods.
Definition: overload.h:35
Represents class that use to determine one of const and non const overloaded methods.
Definition: overload.h:53
static constexpr auto of(result_t(type_t::*method)(args_t...)) noexcept -> decltype(method)
Returns a pointer to an overloaded method. The template parameter is the list of the argument types o...
Definition: overload.h:27
#define const_overload_
Helper keyword that use to determine one of const overloaded methods.
Definition: overload.h:99