forked from natto1784/ooplab
20 lines
345 B
C++
20 lines
345 B
C++
#include <iostream>
|
|
|
|
template <typename T>
|
|
std::enable_if_t<std::is_integral<T>::value, T> fn(T x) {
|
|
return x * x;
|
|
}
|
|
|
|
template <typename T>
|
|
std::enable_if_t<std::is_floating_point<T>::value, T> fn(T x) {
|
|
return --x;
|
|
}
|
|
|
|
int main() {
|
|
float x = 4.4;
|
|
|
|
std::cout << "floating: " << fn((double)5.3) << "\nintegral: " << fn(4l);
|
|
|
|
return 0;
|
|
}
|