mirror of
https://github.com/esphome/esphome.git
synced 2025-11-16 23:05:46 +00:00
tweak
This commit is contained in:
@@ -54,7 +54,7 @@ optional<size_t> Select::active_index() const {
|
|||||||
optional<std::string> Select::at(size_t index) const {
|
optional<std::string> Select::at(size_t index) const {
|
||||||
if (this->has_index(index)) {
|
if (this->has_index(index)) {
|
||||||
const auto &options = traits.get_options();
|
const auto &options = traits.get_options();
|
||||||
return std::string(options[index]);
|
return std::string(options.at(index));
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void TuyaSelect::dump_config() {
|
|||||||
this->select_id_, this->is_int_ ? "int" : "enum");
|
this->select_id_, this->is_int_ ? "int" : "enum");
|
||||||
const auto &options = this->traits.get_options();
|
const auto &options = this->traits.get_options();
|
||||||
for (size_t i = 0; i < this->mappings_.size(); i++) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -322,6 +322,11 @@ template<typename T> class FixedVector {
|
|||||||
T &operator[](size_t i) { return data_[i]; }
|
T &operator[](size_t i) { return data_[i]; }
|
||||||
const T &operator[](size_t i) const { 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
|
// Iterator support for range-based for loops
|
||||||
T *begin() { return data_; }
|
T *begin() { return data_; }
|
||||||
T *end() { return data_ + size_; }
|
T *end() { return data_ + size_; }
|
||||||
|
|||||||
Reference in New Issue
Block a user