1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <type_traits>
template <typename T>
void process_integral(T value) {
static_assert(std::is_integral<T>::value, "T must be an integral type");
std::cout << "Processing integral value: " << value << std::endl;
}
int main() {
process_integral(42);
// Uncommenting the next line would result in a compile-time error
// process_integral(3.14);
return 0;
}
Back to static_assert