std::integral(3)
This is the std::integral(3) page from the C++ Standard Library (the header spells it C++ Standard Libary, and honestly? iconic typo energy π
), and bestie, itβs giving concept-cute.
π NAME π
std::integral β std::integral. Thatβs the name, no notes, we move.
β¨ SYNOPSIS β¨
Okay so first things first: this lil concept lives in the header <concepts>, and itβs been here since C++20.
Defined in header <concepts>
template< class T > (since C++20)
concept integral = std::is_integral_v<T>;
The concept integral<T> is satisfied if and only if T is an integral type. No cap, thatβs the whole vibe check.
πΈ EXAMPLE πΈ
Run this code, bestie β itβs a whole overload moment:
// Run this code
#include <concepts>
#include <iostream>
void print(std::integral auto i)
{
std::cout << "Integral: " << i << '\n';
}
void print(auto x)
{
std::cout << "Non-integral: " << x << '\n';
}
int main()
{
std::cout << std::boolalpha;
static_assert(std::integral<bool>);
print(true);
static_assert(std::integral<char>);
print('o');
static_assert(std::integral<int>);
print(007);
static_assert( ! std::integral<double> );
print(2e2);
static_assert( ! std::integral<decltype("")> );
print("β«β«β«");
}
π OUTPUT π
The output is literally this, character for character:
Integral: true
Integral: o
Integral: 7
Non-integral: 200
Non-integral: β«β«β«
π SEE ALSO π
is_integralβ checks if a type is an integral type (C++11) (class template)
mwah π this lil page came from http://cppreference.com, version/date 2024.06.10, and itβs the std::integral(3) page β periodt. π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms