forked from natto1784/ooplab
19
lab8/24.cpp
Normal file
19
lab8/24.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#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;
|
||||
}
|
Reference in New Issue
Block a user