diff --git a/include/bout/options.hxx b/include/bout/options.hxx index 87503b0a22..b68364c60c 100644 --- a/include/bout/options.hxx +++ b/include/bout/options.hxx @@ -355,7 +355,7 @@ public: /// Return true if this value has attribute \p key bool hasAttribute(const std::string& key) const { - return attributes.find(key) != attributes.end(); + return attributes.contains(key); } /// Set attributes, overwriting any already set @@ -579,7 +579,7 @@ public: value_used = true; // Note this is mutable output_info << "\tOption " << full_name << " = " << val; - if (attributes.count("source")) { + if (attributes.contains("source")) { // Specify the source of the setting output_info << " (" << bout::utils::variantToString(attributes.at("source")) << ")"; } @@ -907,7 +907,7 @@ private: // If already set, and not time evolving then check for changing values // If a variable has a "time_dimension" attribute then it is assumed // that updates to the value is ok and don't need to be forced. - if (isSet() && (attributes.find("time_dimension") == attributes.end())) { + if (isSet() && (!attributes.contains("time_dimension"))) { // Check if current value the same as new value if (!bout::utils::variantEqualTo(value, val)) { if (force or !bout::utils::variantEqualTo(attributes["source"], source)) { diff --git a/src/sys/options.cxx b/src/sys/options.cxx index 85cfa7a49a..dbbe372298 100644 --- a/src/sys/options.cxx +++ b/src/sys/options.cxx @@ -1053,9 +1053,9 @@ bout::details::OptionsFormatterBase::format(const Options& options, fmt::format_to(ctx.out(), " = {}", as_str); } - const bool has_doc = options.attributes.count("doc") != 0U; - const bool has_source = options.attributes.count("source") != 0U; - const bool has_type = options.attributes.count("type") != 0U; + const bool has_doc = options.attributes.contains("doc"); + const bool has_source = options.attributes.contains("source"); + const bool has_type = options.attributes.contains("type"); std::vector comments;