Я пытаюсь написать фиктивную функцию устранения дребезга на C++. Вот что я написал: [code] #include using namespace std; using namespace chrono; functiondebounce(function&f , int period){ function fn = [&](int per){ static auto init_time = high_resolution_clock::now(); auto final_time = high_resolution_clock::now(); if ( duration_cast(final_time - init_time).count() > per){ f(); } init_time = final_time; }; return fn; } int main(void){ int x = 0; function f = [&x](void){ x++; }; function xdf = debounce(f , 30); std::this_thread::sleep_for(milliseconds(300)); xdf(300); xdf(300); std::this_thread::sleep_for(milliseconds(300)); xdf(300); if(x>=3 || x != 2){ cout