Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Изволов#8
//g++ 5.4.0 // Реализовать функцию universal_swap #include <algorithm> #include <cassert> namespace ns { struct swappable { explicit swappable(int x): x(x) {} // Ни копировать, ни переносить нельзя. swappable(const swappable &) = delete ; swappable(swappable &&) = delete ; swappable& operator= (const swappable &) = delete ; swappable& operator= (swappable &&) = delete ; void swap ( swappable& that ) { std::swap( that.x, this->x); } int x; }; void swap( swappable& l, swappable& r) { l.swap (r); } } template <typename T> void universal_swap(T& left, T& right); // <-- int main () { auto x = 4; auto y = -1; universal_swap(x, y); // <-- assert(x == -1); assert(y == 4); ns::swappable a(3); ns::swappable b(42); universal_swap(a, b); // <-- assert(a.x == 42); assert(b.x == 3); }
run
|
edit
|
history
|
help
0
Sort row sorted matrix
scope new delete
Beadandó
C++ Solar eclipse program(Shoushi integrated) 1568 - 1644 also check Lunar eclipse for Xing Yunlu
HashConPar
HeapSort
Microsoft - MaxEmployeeAttendence (R repititions - Semi Optimised DP)
MatrixVectorConversion
341 30 - B
remove_30-Seconds-of-C++