Skip to content

Commit

Permalink
[custom-completion-sorting] ranges.hh: more specific parameter name
Browse files Browse the repository at this point in the history
The static_gather function has a template parameter that decides if
it shall fail when there are *more* elements than expected.

The next commit wants to add another template parameter that decides
if static_gather shall succeed when there are *fewer* elements than
expected.

Let's rename the first template parameter to avoid a perceived overlap.
  • Loading branch information
krobelus committed Apr 16, 2023
1 parent 9155376 commit 27ba689
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ranges.hh
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ auto gather()
}};
}

template<typename ExceptionType, bool exact_size, size_t... Indexes>
template<typename ExceptionType, bool throw_on_extra_elements, size_t... Indexes>
auto elements()
{
return ViewFactory{[=] (auto&& range) {
Expand All @@ -660,22 +660,22 @@ auto elements()
};
// Note that initializer lists elements are guaranteed to be sequenced
Array<std::remove_cvref_t<decltype(*begin(range))>, sizeof...(Indexes)> res{{elem(Indexes)...}};
if (exact_size and it != end_it)
if (throw_on_extra_elements and it != end_it)
throw ExceptionType{sizeof...(Indexes)};
return res;
}};
}

template<typename ExceptionType, bool exact_size, size_t... Indexes>
template<typename ExceptionType, bool throw_on_extra_elements, size_t... Indexes>
auto static_gather_impl(std::index_sequence<Indexes...>)
{
return elements<ExceptionType, exact_size, Indexes...>();
return elements<ExceptionType, throw_on_extra_elements, Indexes...>();
}

template<typename ExceptionType, size_t size, bool exact_size = true>
template<typename ExceptionType, size_t size, bool throw_on_extra_elements = true>
auto static_gather()
{
return static_gather_impl<ExceptionType, exact_size>(std::make_index_sequence<size>());
return static_gather_impl<ExceptionType, throw_on_extra_elements>(std::make_index_sequence<size>());
}

}
Expand Down

0 comments on commit 27ba689

Please sign in to comment.