#include <ugmisc/member.hpp>
|
|
template<class... T> |
| constexpr auto | operator() (T &&...objs) const |
|
| template<class F> |
| static constexpr default_function< F > | fallback (F &&f) |
| template<class... T> |
| static constexpr wrapped_objects< void, T... > | with (T &&...objs) |
template<class Access>
struct member_caller< Access >
Calls a named member function of objects, trying them in sequence until one will accept the arguments, optionally providing a fallback default value.
For example:
#define UGMISC_DECL_MEMBER_ACCESS(TNAME, NAME)
Definition member.hpp:165
static constexpr default_function< F > fallback(F &&f)
Definition member.hpp:942
val is the value of the first of these expressions which is valid:
- x.foo(1, 2)
- y.foo(1, 2)
- get_default(1, 2)
- get_default()
It may be more convenient to use member_caller as an object.
auto val = caller.
fallback( get_default )(x, y)(1, 2);
Definition member.hpp:762
...or even (if it is safe to keep the references to x and y alive):
◆ fallback()
template<class Access>
template<class F>
| constexpr default_function< F > member_caller< Access >::fallback |
( |
F && | f | ) |
|
|
inlinestaticconstexpr |
- Parameters
-
| f | A function or other callable which provides a default value if none of the objects can be called. |
◆ with()
template<class Access>
template<class... T>
| constexpr wrapped_objects< void, T... > member_caller< Access >::with |
( |
T &&... | objs | ) |
|
|
inlinestaticconstexpr |
- Parameters
-
| objs | Objects to try calling. |
The documentation for this struct was generated from the following file: