const int max_v = 10; void fun(int y) { const int max_v = [&]{ // локальный max_v перекрывает глобальный max_v return std::min(max_v, y); }(); ... }