Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add calculate_default to initialize option by default in `IndicesOp…
Browse files Browse the repository at this point in the history
…tion` constructor
aartdem committed Nov 29, 2023

Verified

This commit was signed with the committer’s verified signature.
raklaptudirm Rak Laptudirm
1 parent 3fcf006 commit b89a960
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/core/config/indices/option.cpp
Original file line number Diff line number Diff line change
@@ -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<config::IndicesType>::DefaultFunc calculate_default)
: common_option_(name, description, {}, NormalizeIndices, nullptr,
std::move(calculate_default)) {}

std::string_view IndicesOption::GetName() const {
return common_option_.GetName();
3 changes: 2 additions & 1 deletion src/core/config/indices/option.h
Original file line number Diff line number Diff line change
@@ -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<config::IndicesType>::DefaultFunc calculate_default = nullptr);

[[nodiscard]] std::string_view GetName() const;

0 comments on commit b89a960

Please sign in to comment.