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
Linker error while passing constexpr variable as const &
001
Balanced Insert Example
tuple, order of members
Template arguments may contain calls to constexpr functions.
unordered graphs search
function pointer
projecte1
INHERIT_CTORS default constructor
ternary test c++14