labs 8: init

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-26 17:30:37 +05:30
parent 7ba9554ed5
commit 4824ab9855
6 changed files with 129 additions and 0 deletions

19
lab8/24.cpp Normal file
View 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;
}