ugmisc 0.2
Miscellaneous C++ header library
Loading...
Searching...
No Matches
ugmisc::call_foo_method< T > Struct Template Reference

#include <ugmisc/member.hpp>

Public Types

template<class... U>
using matched_type = ???

Public Member Functions

template<class... U>
constexpr decltype(auto) operator() (U &&...) const

Static Public Member Functions

template<class... U>
static constexpr decltype(auto) call (U &&...args)
template<class F>
static constexpr auto fallback (F &&functor)
template<class... U>
static constexpr bool is_matched (U &&...)
template<class... U>
static matched_type< U... > declval_matched (U &&...) noexcept

Static Public Attributes

template<class... U>
static constexpr bool is_matched_v = ???

Detailed Description

template<class... T>
struct ugmisc::call_foo_method< T >

This is an example of the type of template that is created by the UGMISC_NAMED_MEMBER_STATIC_METHOD_CALL and UGMISC_MEMBER_STATIC_METHOD_CALL macros.

In this example the NAME parameter of the macro is foo.

Member Typedef Documentation

◆ matched_type

template<class... T>
template<class... U>
using ugmisc::call_foo_method< T >::matched_type = ???

This is the type whose foo method would be called if the given parameter types were passed. If there is no suitable type then use of matched_type will not be valid.

Member Function Documentation

◆ call()

template<class... T>
template<class... U>
constexpr decltype(auto) ugmisc::call_foo_method< T >::call ( U &&... args)
staticconstexpr

Forwards args to the first T::foo static method that can be called with those parameter types, and returns the result. If no such method exists, the call is a compile time error.

◆ declval_matched()

template<class... T>
template<class... U>
matched_type< U... > ugmisc::call_foo_method< T >::declval_matched ( U && ...)
staticnoexcept

This declaration has no matching definition. It can be used where you would use std::declval<>(). It is an expression of the same type as the type whose static method would be called if arguments of type U... were passed to call.

◆ fallback()

template<class... T>
template<class F>
constexpr auto ugmisc::call_foo_method< T >::fallback ( F && functor)
staticconstexpr

Provides a fallback default value getter. This is a callable rather than the default value, so that default values which have a runtime overhead to create and destroy can be avoided where they are not needed.

The callable may accept the forwarded arguments that were supposed to be passed to a static foo() method of one of the T type parameters, or it may accept no arguments. For example:

call_foo_method<X, Y, Z>::fallback(default_foo)(args...);
static constexpr auto fallback(F &&functor)

This will make the first valid call and return the results:

  • X::foo(args...)
  • Y::foo(args...)
  • Z::foo(args...)
  • default_foo(args...)
  • default_foo()
Returns
An object which is callable just like an instance of call_foo_method is callable, but will fall back to calling the provided function or functor if the type parameters don't support the method call.
Parameters
functorCreates a default return value if needed.

◆ is_matched()

template<class... T>
template<class... U>
constexpr bool ugmisc::call_foo_method< T >::is_matched ( U && ...)
staticconstexpr
See also
is_matched_v

◆ operator()()

template<class... T>
template<class... U>
decltype(auto) ugmisc::call_foo_method< T >::operator() ( U && ...) const
constexpr

Forwards its arguments to the static method call_foo_method::call. So the following two statements are effectively the same:

Definition member.hpp:67
static constexpr decltype(auto) call(U &&...args)

Member Data Documentation

◆ is_matched_v

template<class... T>
template<class... U>
bool ugmisc::call_foo_method< T >::is_matched_v = ???
staticconstexpr

True if a call with the given parameter types is valid.

Template Parameters
UThe function call parameter types.

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