From de2671ae309a1e7332eb5b2353b8f46a66abdac8 Mon Sep 17 00:00:00 2001 From: Artem Demchenko Date: Wed, 29 Nov 2023 18:35:20 +0300 Subject: [PATCH] `IndicesOption`: Add function to initialize option by default --- src/core/config/indices/option.cpp | 6 ++++-- src/core/config/indices/option.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/config/indices/option.cpp b/src/core/config/indices/option.cpp index db2d5034a1..8075afee9a 100644 --- a/src/core/config/indices/option.cpp +++ b/src/core/config/indices/option.cpp @@ -13,8 +13,10 @@ static void NormalizeIndices(config::IndicesType& indices) { indices.erase(std::unique(indices.begin(), indices.end()), indices.end()); } -IndicesOption::IndicesOption(std::string_view name, std::string_view description) - : common_option_(name, description, {}, NormalizeIndices) {} +IndicesOption::IndicesOption(std::string_view name, std::string_view description, + typename Option::DefaultFunc calculate_default) + : common_option_(name, description, {}, NormalizeIndices, nullptr, + std::move(calculate_default)) {} std::string_view IndicesOption::GetName() const { return common_option_.GetName(); diff --git a/src/core/config/indices/option.h b/src/core/config/indices/option.h index 62d07b93bc..8250e2a2d7 100644 --- a/src/core/config/indices/option.h +++ b/src/core/config/indices/option.h @@ -9,7 +9,8 @@ namespace config { // This class is meant for creating options that are collections of indices. struct IndicesOption { - IndicesOption(std::string_view name, std::string_view description); + IndicesOption(std::string_view name, std::string_view description, + typename Option::DefaultFunc calculate_default = nullptr); [[nodiscard]] std::string_view GetName() const;