#include <vector>
#include <iostream>
#include <functional>
class Yoba {
public:
Yoba();
Yoba(const Yoba& r);
auto getW(void);
private:
int w;
static int v;
};
std::vector<std::reference_wrapper<Yoba>> global_shit;
Yoba::Yoba() : w{ v } { ++v; global_shit.push_back(std::ref(*this)); };
Yoba::Yoba(const Yoba& r) : w{ 0 } {};
auto Yoba::getW(void) { return w; }
int Yoba::v{ 1 };
int
main()
{
Yoba yoba[ 10 ];
for (auto& i : global_shit)
{
std::cout << i.get().getW() << std::endl;
}
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KCmNsYXNzIFlvYmEgewpwdWJsaWM6CglZb2JhKCk7CglZb2JhKGNvbnN0IFlvYmEmIHIpOwoJYXV0byBnZXRXKHZvaWQpOwoJCnByaXZhdGU6CglpbnQgdzsKCXN0YXRpYyBpbnQgdjsKfTsKCnN0ZDo6dmVjdG9yPHN0ZDo6cmVmZXJlbmNlX3dyYXBwZXI8WW9iYT4+IGdsb2JhbF9zaGl0OwoKWW9iYTo6WW9iYSgpIDogd3sgdiB9IHsgKyt2OyAgZ2xvYmFsX3NoaXQucHVzaF9iYWNrKHN0ZDo6cmVmKCp0aGlzKSk7IH07CllvYmE6OllvYmEoY29uc3QgWW9iYSYgcikgOiB3eyAwIH0ge307CmF1dG8gWW9iYTo6Z2V0Vyh2b2lkKSB7IHJldHVybiB3OyB9CgppbnQgWW9iYTo6dnsgMSB9OwoKaW50Cm1haW4oKQp7CglZb2JhIHlvYmFbIDEwIF07Cglmb3IgKGF1dG8mIGkgOiBnbG9iYWxfc2hpdCkKCXsKCQlzdGQ6OmNvdXQgPDwgaS5nZXQoKS5nZXRXKCkgPDwgc3RkOjplbmRsOyAKCX0KCXJldHVybiAwOwp9Cgo=