19
lab8/22.cpp
Normal file
19
lab8/22.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <iostream>
|
||||
|
||||
template <typename T, std::enable_if_t<std::is_arithmetic<T>::value, T> = 0>
|
||||
void swap(T &x, T &y) {
|
||||
x += y;
|
||||
y = x - y;
|
||||
x -= y;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char x = '[';
|
||||
char y = 'w';
|
||||
|
||||
swap(x, y);
|
||||
|
||||
std::cout << "x = " << x << ", y = " << y;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user