#include <vector>
class TimerFriend
{
public:
TimerFriend(const TimerFriend&) = default;
TimerFriend& operator =(const TimerFriend&) = default;
private:
TimerFriend() {}
friend class Timer;
};
class Timer {
private:
int timeLeft;
public:
Timer(unsigned int ms, const TimerFriend&) : timeLeft(ms) {}
static std::vector<Timer> instances;
static void create(unsigned int ms) {
instances.emplace_back(ms, TimerFriend());
}
};
std::vector<Timer> Timer::instances;
int main()
{
Timer::create(100);
}
I2luY2x1ZGUgPHZlY3Rvcj4KCiAgICBjbGFzcyBUaW1lckZyaWVuZAogICAgewogICAgcHVibGljOgogICAgICBUaW1lckZyaWVuZChjb25zdCBUaW1lckZyaWVuZCYpID0gZGVmYXVsdDsKICAgICAgVGltZXJGcmllbmQmIG9wZXJhdG9yID0oY29uc3QgVGltZXJGcmllbmQmKSA9IGRlZmF1bHQ7CiAgICAKICAgIHByaXZhdGU6CiAgICAgIFRpbWVyRnJpZW5kKCkge30KICAgIAogICAgICBmcmllbmQgY2xhc3MgVGltZXI7CiAgICB9OwoKICAgIGNsYXNzIFRpbWVyIHsKICAgICAgICBwcml2YXRlOgogICAgICAgICAgICBpbnQgdGltZUxlZnQ7CiAgICAKICAgICAgICBwdWJsaWM6CiAgICAgICAgICAgIFRpbWVyKHVuc2lnbmVkIGludCBtcywgY29uc3QgVGltZXJGcmllbmQmKSA6IHRpbWVMZWZ0KG1zKSB7fQoKICAgICAgICAgICAgc3RhdGljIHN0ZDo6dmVjdG9yPFRpbWVyPiBpbnN0YW5jZXM7CiAgICAgICAgICAgIHN0YXRpYyB2b2lkIGNyZWF0ZSh1bnNpZ25lZCBpbnQgbXMpIHsKICAgICAgICAgICAgICAgIGluc3RhbmNlcy5lbXBsYWNlX2JhY2sobXMsIFRpbWVyRnJpZW5kKCkpOwogICAgICAgICAgICB9CiAgICB9OwogICAgCiAgICBzdGQ6OnZlY3RvcjxUaW1lcj4gVGltZXI6Omluc3RhbmNlczsKCmludCBtYWluKCkKewogICAgVGltZXI6OmNyZWF0ZSgxMDApOwp9