template<class Access, class... T>
struct static_member_value< Access, T >
Finds a reference to a named static member value in the first type among T... which has a static value accessible by that name.
The Access is responsible for knowing the name to use, and is a type declared with the help of the UGMISC_DECL_MEMBER_ACCESS macro.
For example:
auto& foo1 = Getter::get();
decltype(auto) foo2 = Getter::get( defaultFoo, 1, 2 );
#define UGMISC_DECL_MEMBER_ACCESS(TNAME, NAME)
Definition member.hpp:165
Definition member.hpp:1557
In the example above, the value of foo1 will be the first of the following which is valid:
- A reference to X::foo.
- A reference to Y::foo.
If neither of those is valid, the declaration is an error.
The value of foo2 will be the first valid value of the following:
- The same as foo1
- defaultFoo(1, 2)
- Template Parameters
-
| Access | A type declared using UGMISC_DECL_MEMBER_ACCESS. This is responsible for accessing the correctly named static member, according to the second argument passed to the macro. |
| T | The types in which to look for the named member. |
template<class Access, class... T>
template<class F, class... A>
| constexpr decltype(auto) static_member_value< Access, T >::get |
( |
F && | default_get, |
|
|
A &&... | args ) |
|
staticconstexpr |
Like get() but with a default value. The value is provided by a callable parameter, which is passed the args.
This way side effects of getting the default value can be avoided if it is not needed.
- Parameters
-
| default_get | A function or callable object. |
| args | Optional arguments to pass to default_get. |