|
I was surprised when
if (const auto& fcv = serverGlobalParams.featureCompatibility; fcv.isVersionInitialized() &&
|
fcv.isGreaterThanOrEqualTo(ServerGlobalParams::FeatureCompatibility::Version::kVersion47)) {
|
// ...
|
}
|
wouldn't compile. So the newly-added accessors (isLessThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isGreaterThan, isUpgradingOrDowngrading) should be const-qualified.
However in addition to this it might be better if serverGlobalParams.featureCompatibility was a const ref, with some other name for the places that legitimately need to modify it, eg.
struct ServerGlobalParams {
|
// ...
|
|
struct FeatureCompatibility {
|
// ...
|
- } featureCompatibility;
|
+ } featureCompatibilityMutable;
|
+ const FeatureCompatibility& featureCompatibility = featureCompatibilityMutable;
|
|
// ...
|
};
|
This would have caught the missing const-qualifier on the accessors when they were added (in addition to helping prevent accidents).
|