Parameterized constraints

There are two kinds of parameterized constraints, one to check if an expression between two operands are allowed, and one for checking a constant value. It’s not legal to put a constraint on non-constant values.

Exception constraints

Exception constraints check if an expression E is marked noexcept, and returns true only if it evaluates to noexcept(true).

Argument deduction constraints

Argument deduction constraints are similar to implicit conversion constraints, except argument deduction constraints have one or more placeholders in the trailing return type field.

Type and implicit conversion constraints

Type constraints

Type constraints restrict by limiting the type accepted. By this you can only accept types, which contain some properties or a set of subtypes.

The nine types of constraints

With Concepts Lite there are nine types of constraints. Each serves a different purpose, and those nine types of constraints are:

Function and variable concepts

In general, there are two kinds of distinct concepts. Those are function concepts and variable concepts. They are similar to their non-concept siblings template functions and template variables. If you haven’t heard about template variables, you’re not alone. Those are new in C++14, and allows you to define a variable as a template. However, variable concepts are modeled around template variables, so they will be covered.

Getting started with arithmetic concepts

Not long ago, I implemented a Matrix class with template expressions. Sadly, I cannot release it to the public because it belongs to my employer. Such libraries dealing with arithmetic will benefit greatly from concepts. The compile errors from not implemented operators are horrendous.

Your own concepts

The easiest concept is probably the boolean concepts true and false.