1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 23:21:54 +00:00
This commit is contained in:
J. Nick Koston
2025-10-24 06:46:54 -07:00
parent 4135e0b5db
commit b2cded14ec
3 changed files with 7 additions and 2 deletions

View File

@@ -54,7 +54,7 @@ optional<size_t> Select::active_index() const {
optional<std::string> Select::at(size_t index) const {
if (this->has_index(index)) {
const auto &options = traits.get_options();
return std::string(options[index]);
return std::string(options.at(index));
} else {
return {};
}

View File

@@ -51,7 +51,7 @@ void TuyaSelect::dump_config() {
this->select_id_, this->is_int_ ? "int" : "enum");
const auto &options = this->traits.get_options();
for (size_t i = 0; i < this->mappings_.size(); i++) {
ESP_LOGCONFIG(TAG, " %i: %s", this->mappings_.at(i), options[i]);
ESP_LOGCONFIG(TAG, " %i: %s", this->mappings_.at(i), options.at(i));
}
}

View File

@@ -322,6 +322,11 @@ template<typename T> class FixedVector {
T &operator[](size_t i) { return data_[i]; }
const T &operator[](size_t i) const { return data_[i]; }
/// Access element with bounds checking (matches std::vector behavior)
/// Note: No exception thrown on out of bounds - caller must ensure index is valid
T &at(size_t i) { return data_[i]; }
const T &at(size_t i) const { return data_[i]; }
// Iterator support for range-based for loops
T *begin() { return data_; }
T *end() { return data_ + size_; }