#include <ugmisc/member.hpp>
Public Types | |
| template<class... Args> | |
| using | matched_type = typename caller<void, types_list, Args...>::type |
| template<class... Args> | |
| using | safe_matched_type |
Public Member Functions | |
| template<class... Args> | |
| constexpr decltype(auto) | operator() (Args &&...args) const |
Static Public Member Functions | |
| template<class... Args> | |
| static constexpr bool | is_matched (Args &&...) |
| template<class... Args> | |
| static constexpr decltype(auto) | call (Args &&...args) |
| template<class F> | |
| static constexpr member_::fallback_caller< static_member_caller, std::remove_reference_t< F > > | fallback (F &&functor) |
| template<class... Args> | |
| static matched_type< Args... > | declval_matched (Args &&...) noexcept |
| template<class... Args> | |
| static matched_type< Args... > | declval_matched () noexcept |
| template<class... Args> | |
| static safe_matched_type< Args... > | safe_declval_matched (Args &&...) noexcept |
| template<class... Args> | |
| static safe_matched_type< Args... > | safe_declval_matched () noexcept |
Static Public Attributes | |
| template<class... Args> | |
| static constexpr bool | is_matched_v |
Can find, among a list of types, a static method with a particular name, which accepts certain parameter types, and forward arguments to it.
Also provides the ability to revert to a default value if no suitable call can be made. This can be done in such a way that the default value does not have to be instantiated if it is not needed.
| Access | A type, which may be declared using UGMISC_DECL_MEMBER_ACCESS, which is responsible for knowing the name of the function to call. |
| T | A list of types which may or may not contain the named static method. The first one which is suitable will be selected. |
For example, if you want to forward args... to the first of X::foo(), Y::foo(), and Z::foo() which accepts those arguments, you can do this:
Continuing the above example:
The first of the following expressions which is valid is what the above expression is equivalent to:
f would typically be a lambda.
If all you want to know is whether the call with those arguments would be valid:
You can also find the type whose foo method would be called:
| using static_member_caller< Access, T >::matched_type = typename caller<void, types_list, Args...>::type |
The type, which is one of the T... template parameter pack, that would be called if call were called with these argument types.
| using static_member_caller< Access, T >::safe_matched_type |
If is_matched_v<Args...> is true: the type whose named (by Access) method would be called by call<Args...>.
If is_matched_v<Args...> is false: void`.
|
inlinestaticconstexpr |
Forward the arguments, using std::forward, to a static method of one of the types T....
The name of the static method is determined by the Access template parameter.
The first type for which the call would be valid is used.
|
staticnoexcept |
Like declval_matched(Args&&...) but is more convenient when you have argument types handy rather than argument expressions.
|
staticnoexcept |
Can be used like std::declval, passing it the type whose named method the arguments would be forwarded to.
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
true if the call with the provided arguments would be valid.
|
inlineconstexpr |
An instance of static_member_caller is callable using its operator (). It simply forwards its arguments, using std::forward, to its static call method.
|
staticnoexcept |
|
staticnoexcept |
Like declval_matched(Args&&...) but it will create a void expression instead of a compile error. This is likely to cause a compile error in whatever you were trying to do anyway.
|
staticconstexpr |
true if one of the listed types has a static method named by the Access template parameter, which would accept the arguments of the same type as Args....