ugmisc 0.2-76
Miscellaneous C++ header library
Loading...
Searching...
No Matches
member_type_access< Access, T > Struct Template Reference

#include <ugmisc/member.hpp>

Public Types

using type = ???
using safe_type = ???

Static Public Attributes

static constexpr bool has_member = ???
static constexpr bool has_default = ???
static constexpr bool has_type = has_member || has_default

Detailed Description

template<class Access, class... T>
struct member_type_access< Access, T >

Instances of this template define member types which alias a named member type of one of their template parameters.

Template Parameters
AccessA type defined by UGMISC_DECL_MEMBER_ACCESS
TA list of types to search, in order, for a member type of the correct name. The name is determined by Access. If one of the types is in instance of default_type, then default_type::type is used as a default type if none of the other types has the correct member.
Note
It is an error to supply two or more instances of default_type.

For example:

UGMISC_DECL_MEMBER_ACCESS(FooType, foo); // Declares FooType.
using type = ugmisc::member_type_access<FooType, X, Y, ugmisc::default_type<void>>;
type::has_member; // Whether X or Y has the named type member.
type::has_default; // Whether a default type was provided.
type::has_type; // Whether a type was found (equal to has_member||has_default).
typename type::type; // Only defined if type::has_type is true.
typename type::safe_type; // Same as type if defined, otherwise void.
#define UGMISC_DECL_MEMBER_ACCESS(TNAME, NAME)
Definition member.hpp:165
??? type
Definition member.hpp:1505
Note
The types in the T... parameter pack are turned into a type_list using flatten_t. This means you can include type_lists of types you want to include in the list in the template parameters. If you really want one of the checked types to be a type_list, wrap it in a wrapped_list.

Member Typedef Documentation

◆ safe_type

template<class Access, class... T>
using member_type_access< Access, T >::safe_type = ???

If type is declared, safe_type is the same type. Otherwise, safe_type is void.

◆ type

template<class Access, class... T>
using member_type_access< Access, T >::type = ???
Note
This is not actually declared if has_type is false.

The type is the first T::foo which is a valid type expression, if there is one and T is not an instance of default_type.

If there is no such valid expression, the type will be the value of T::type where T is the single member of the T... parameter pack which is an instance of default_type.

Member Data Documentation

◆ has_default

template<class Access, class... T>
bool member_type_access< Access, T >::has_default = ???
staticconstexpr

true if a default type is one of the template arguments. In other words, one of the types in the T... arguments is an instance of default_type.

◆ has_member

template<class Access, class... T>
bool member_type_access< Access, T >::has_member = ???
staticconstexpr

true if one of the types has a suitably named and accessible member type.

◆ has_type

template<class Access, class... T>
bool member_type_access< Access, T >::has_type = has_member || has_default
staticconstexpr

true if a type was found, either as a named member of a searched type, or as the default type.


The documentation for this struct was generated from the following file: