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

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback