TModels

Utilities for concepts checks.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Templates/Models.h

Include

#include "Templates/Models.h"

Syntax

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

Remarks

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.

Specializations

Functions

Name Description

Public function Static

char(&

 

Resolve

(
    decltype&::< ... >Ts*
)

Public function Static

char(&

 

Resolve

(
    ...
)

Constants

Name

Description

Value

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss