一呼百應, "one call, a hundred responses"
Loading...
Searching...
No Matches
concepts.hpp File Reference
#include <concepts>
Include dependency graph for concepts.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ein_ensures(concept, x)
 statically checks that a concept is satisfied by the type of an expression
 

Detailed Description

SPDX-FileType: Source
SPDX-FileCopyrightText: 2024 Edward Kmett <ekmett@gmail.com>
SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0

Definition in file concepts.hpp.

Macro Definition Documentation

◆ ein_ensures

#define ein_ensures ( concept,
x )
Value:
( \
[]<typename T> static constexpr noexcept { \
static_assert(concept<T>, #concept " not satisfied"); \
}.template operator()<decltype(x)>(), \
(x) \
)

statically checks that a concept is satisfied by the type of an expression

This is expected most often to be used inline in a return statement:

auto foo(integral auto x, integral auto y) {
return ein_ensures(integral, x + y);
}
#define ein_ensures(concept, x)
statically checks that a concept is satisfied by the type of an expression
Definition concepts.hpp:31
Parameters
conceptthe name of a C++ concept to check
xthe expression to check returns a result that satisfies it
Returns
x

Definition at line 31 of file concepts.hpp.

31#define ein_ensures(concept, x) \
32 ( \
33 []<typename T> static constexpr noexcept { \
34 static_assert(concept<T>, #concept " not satisfied"); \
35 }.template operator()<decltype(x)>(), \
36 (x) \
37 )