Ark Server API (ASA) - Wiki
|
#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 |
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.
|
static |