C++ 23 · Classes, memory and templates

Constrain a template with a concept

Accept only integral types and get clear error messages otherwise (C++20).

template <std::integral T>
T twice(T value) {
    return value * 2;
}

Official C++ 23 documentation

More classes, memory and templates commands

All classes, memory and templates commands · C++ 23 cheatsheet

Was this page helpful?