Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TModels< Concept, Args > Struct Template Reference

#include <Models.h>

Static Public Member Functions

template<typename... Ts>
static char(& Resolve (decltype(&Concept::template Requires< Ts... >) *))[2]
 
template<typename... Ts>
static char(& Resolve (...))[1]
 

Static Public Attributes

static constexpr bool Value = sizeof(Resolve<Args...>(0)) == 2
 

Detailed Description

template<typename Concept, typename... Args>
struct TModels< Concept, Args >

Utilities for concepts checks.

In this case, a successful concept check means that a given C++ expression is well-formed. No guarantees are given about the correctness, behavior or complexity of the runtime behaviour of that expression.

Concepts are structs with a rather unusual definition:

struct CConcept { template <[...concept parameters...]> auto Requires([...placeholder variables...]) -> decltype( [...expression(s) to test the validity of...] ); };

The prefix C is reserved for concepts, and concepts should be directly named as an adjective and not like a predicate, i.e.: CEqualityComparable - good CIsComparable - bad CHasEqualsOperator - bad

Concepts can be checked using the TModels trait:

TModels<Concept, [...arguments...]>::Value

The arguments are forwarded to the template parameters of the concept's Requires() function, which will attempt to compile the expression(s) in the return value, and SFINAE is utilized to test whether that succeeded.

The placeholders are simply any variable declarations you need to write your expression(s).

Note that 'legal C++' doesn't necessarily mean that the expression will compile when used. The concept check only tests that the syntax is valid. Instantiation of function template bodies may still fail. See the CContainerLvalueAddable example below. Traits class which does concept checking.

Definition at line 47 of file Models.h.

Member Function Documentation

◆ Resolve() [1/2]

template<typename Concept , typename... Args>
template<typename... Ts>
static char(& TModels< Concept, Args >::Resolve ( ...) )[1]
static

◆ Resolve() [2/2]

template<typename Concept , typename... Args>
template<typename... Ts>
static char(& TModels< Concept, Args >::Resolve ( decltype &::< ... >Ts * ) )[2]
static

Member Data Documentation

◆ Value

template<typename Concept , typename... Args>
constexpr bool TModels< Concept, Args >::Value = sizeof(Resolve<Args...>(0)) == 2
staticconstexpr

Definition at line 55 of file Models.h.


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