Commit 2b5b8b4f authored by Dominik Charousset's avatar Dominik Charousset

Add missing holds_alternative overload

parent b877c738
...@@ -44,6 +44,16 @@ optional<T> get_if(const settings* xs, string_view name) { ...@@ -44,6 +44,16 @@ optional<T> get_if(const settings* xs, string_view name) {
return none; return none;
} }
/// Returns whether `xs` associates a value of type `T` to `name`.
/// @relates config_value
template <class T>
bool holds_alternative(const settings& xs, string_view name) {
using access = select_config_value_access_t<T>;
if (auto value = get_if(&xs, name))
return access::is(*value);
return false;
}
template <class T> template <class T>
T get(const settings& xs, string_view name) { T get(const settings& xs, string_view name) {
auto result = get_if<T>(&xs, name); auto result = get_if<T>(&xs, name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment