Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
std::reference_wrapper
//Title of this code //clang 3.6.0 #include <iostream> #include <vector> #include <functional> int main() { int a = 100; int b = 200; int c = 300; int& cc = c; std::vector<std::reference_wrapper<int>> vec; vec.emplace_back(a); vec.emplace_back(b); vec.emplace_back(cc); std::reference_wrapper<int> x = vec[0]; vec[0] = vec[1]; vec[1] = vec[2]; vec[2] = x; std::cout << a << ", " << b << ", " << c << "\n"; std::cout << vec[0] << ", " << vec[1] << ", " << vec[2] << "\n"; a += 50; b += 50; c += 50; std::cout << vec[0] << ", " << vec[1] << ", " << vec[2] << "\n"; }
run
|
edit
|
history
|
help
0
hello,world !ssn2019
Graphs Iteration1 Undirected.
range based for loop temporary object lifetime issue example
non-deduced context
Rounding float to nearest 1000 (fixed)
Apple is not convertible to itself (clang 3.8.0)
appliWall
LOOL
Maze problem solution
mpi_distributed_sort