1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <type_traits>
template<typename T>
struct Wrapper {
T value;
// Forward reference to is_integral
void printInfo() {
if (std::is_integral<T>::value) {
std::cout << "Integral type" << std::endl;
} else {
std::cout << "Non-integral type" << std::endl;
}
}
};
int main() {
Wrapper<int> intWrapper;
Wrapper<double> doubleWrapper;
intWrapper.printInfo();
doubleWrapper.printInfo();
return 0;
}
Back to forward_reference