summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/util/version/releases.h.tpl35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/mongo/util/version/releases.h.tpl b/src/mongo/util/version/releases.h.tpl
index 787494840cf..f006eed1ed1 100644
--- a/src/mongo/util/version/releases.h.tpl
+++ b/src/mongo/util/version/releases.h.tpl
@@ -223,21 +223,24 @@ inline constexpr std::array extendedFCVTable {
#end for
};
+constexpr decltype(auto) findExtended(FeatureCompatibilityVersion v) {
+ return extendedFCVTable[static_cast<size_t>(v)];
+}
+
+constexpr StringData toString(FeatureCompatibilityVersion v) {
+ return findExtended(v).second;
+}
+
/**
- * A table with mappings between FeatureCompatibilityVersion::kVersion_X_Y and a pointer to the
- * "X.Y"_sd generated by the extended table. Thus, this a subset of the extended table.
+ * Pointers to nodes of the extended table that represent numbered software versions.
+ * Other FCV enum members, such as those representing transitions, are excluded.
*/
inline constexpr std::array standardFCVTable {
#for fcv, _ in filter(lambda p: p not in transition_fcvs, fcv_list):
- std::pair{FeatureCompatibilityVersion::$fcv,
- &extendedFCVTable[static_cast<size_t>(FeatureCompatibilityVersion::$fcv)].second},
+ &findExtended(FeatureCompatibilityVersion::$fcv),
#end for
};
-constexpr StringData toString(FeatureCompatibilityVersion v) {
- return extendedFCVTable[static_cast<size_t>(v)].second;
-}
-
/**
* Parses 'versionString', of the form "X.Y", to its corresponding FCV enum. For example, "5.1"
* will be parsed as FeatureCompatibilityVersion::$fcv_cpp_name(Version("5.1")).
@@ -245,11 +248,9 @@ constexpr StringData toString(FeatureCompatibilityVersion v) {
* enum.
*/
inline FeatureCompatibilityVersion parseVersionForFeatureFlags(StringData versionString) {
- for (const auto& [fcv, record] : standardFCVTable) {
- if (*record == versionString)
- return fcv;
- }
-
+ for (auto ptr : standardFCVTable)
+ if (ptr->second == versionString)
+ return ptr->first;
uasserted(ErrorCodes::BadValue,
fmt::format("Invalid FCV version {} for feature flag.", versionString));
}
@@ -259,12 +260,10 @@ inline FeatureCompatibilityVersion parseVersionForFeatureFlags(StringData versio
* version of the form 'X.Y'. Non-standard enums are transition enums, 'kInvalid' and
* 'kUnsetDefaultLastLTSBehavior'.
*/
-inline bool isStandardFCV(FeatureCompatibilityVersion v) {
- for (const auto& [fcv, record] : standardFCVTable) {
- if (v == fcv)
+constexpr bool isStandardFCV(FeatureCompatibilityVersion v) {
+ for (auto ptr : standardFCVTable)
+ if (ptr->first == v)
return true;
- }
-
return false;
}