xtd 0.2.0
overload.h
Go to the documentation of this file.
1 #pragma once
5 #include <functional>
6 
8 namespace xtd {
15  template <typename... args_t>
20  template <typename result_t, typename type_t>
21  constexpr auto operator()(result_t (type_t::*method)(args_t...)) const noexcept -> decltype(method) {return method;}
25  template <typename result_t, typename type_t>
26  static constexpr auto of(result_t (type_t::*method)(args_t...)) noexcept -> decltype(method) {return method;}
27  };
28 
33  template <typename... args_t>
34  struct const_overload {
36 
41  template <typename result_t, typename type_t>
42  constexpr auto operator()(result_t (type_t::*method)(args_t...) const) const noexcept -> decltype(method) {return method;}
44 
46 
51  template <typename result_t, typename type_t>
52  static constexpr auto of(result_t (type_t::*method)(args_t...) const) noexcept -> decltype(method) {return method;}
54  };
55 
60  template <typename... args_t>
61  struct overload : const_overload<args_t...>, non_const_overload<args_t...> {
63  using const_overload<args_t...>::of;
65  using non_const_overload<args_t...>::of;
68 
70 
75  template <typename result_t>
76  constexpr auto operator()(result_t (*method)(args_t...)) const noexcept -> decltype(method) {return method;}
78 
80 
85  template <typename result_t>
86  static constexpr auto of(result_t (*method)(args_t...)) noexcept -> decltype(method) {return method;}
87  };
88 
90  template <typename... args_t>
91  inline const overload<args_t...> overload_;
92 
93  template <typename... args_t>
94  inline const const_overload<args_t...> const_overload_;
95 
96  template <typename... args_t>
97  inline const non_const_overload<args_t...> non_const_overload_;
99 }
100 
107 #define overload_ xtd::overload_
108 
115 #define const_overload_ xtd::const_overload_
116 
123 #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:21
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:123
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:76
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:52
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:42
Represents class that use to determine one of non const overloaded methods.
Definition: overload.h:16
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:86
#define overload_
Helper keyword that use to determine one of const and non const overloaded methods.
Definition: overload.h:107
Represents class that use to determine one of const overloaded methods.
Definition: overload.h:34
Represents class that use to determine one of const and non const overloaded methods.
Definition: overload.h:61
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:26
#define const_overload_
Helper keyword that use to determine one of const overloaded methods.
Definition: overload.h:115