1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-20 20:22:27 +01:00

Upgrade to use C++20 (#9135)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Jimmy Hedman
2025-06-27 19:31:50 +02:00
committed by GitHub
parent c0b1f32889
commit 68d66c873e
23 changed files with 59 additions and 63 deletions

View File

@@ -3,6 +3,7 @@
#include "esphome/core/version.h"
#include "esphome/core/hal.h"
#include <algorithm>
#include <ranges>
#ifdef USE_STATUS_LED
#include "esphome/components/status_led/status_led.h"
@@ -184,8 +185,8 @@ void IRAM_ATTR HOT Application::feed_wdt(uint32_t time) {
}
void Application::reboot() {
ESP_LOGI(TAG, "Forcing a reboot");
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
(*it)->on_shutdown();
for (auto &component : std::ranges::reverse_view(this->components_)) {
component->on_shutdown();
}
arch_restart();
}
@@ -198,17 +199,17 @@ void Application::safe_reboot() {
}
void Application::run_safe_shutdown_hooks() {
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
(*it)->on_safe_shutdown();
for (auto &component : std::ranges::reverse_view(this->components_)) {
component->on_safe_shutdown();
}
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
(*it)->on_shutdown();
for (auto &component : std::ranges::reverse_view(this->components_)) {
component->on_shutdown();
}
}
void Application::run_powerdown_hooks() {
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
(*it)->on_powerdown();
for (auto &component : std::ranges::reverse_view(this->components_)) {
component->on_powerdown();
}
}