Skip to content

Commit

Permalink
Fix failing conversion in algo_factory.h
Browse files Browse the repository at this point in the history
  • Loading branch information
BUYT-1 authored and polyntsov committed Jul 24, 2023
1 parent 64ba574 commit 2d3ce09
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/algorithms/algo_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ using StdParamsMap = std::unordered_map<std::string, boost::any>;

namespace details {

inline boost::any GetAny(boost::program_options::variable_value const& value) {
return value.value();
}

inline boost::any GetAny(boost::any const& value) {
return value;
}

template <typename OptionMap>
boost::any ExtractAnyFromMap(OptionMap& options, std::string_view option_name) {
using std::is_same_v, std::decay, boost::program_options::variables_map;
Expand All @@ -26,11 +34,7 @@ boost::any ExtractAnyFromMap(OptionMap& options, std::string_view option_name) {
if (it == options.end()) {
throw std::out_of_range("No option named \"" + string_opt + "\" in parameters.");
}
if constexpr (is_same_v<typename decay<OptionMap>::type, variables_map>) {
return options.extract(it).mapped().value();
} else {
return options.extract(it).mapped();
}
return GetAny(options.extract(it).mapped());
}

template <typename T, typename OptionMap>
Expand All @@ -41,7 +45,7 @@ T ExtractOptionValue(OptionMap&& options, std::string const& option_name) {
template <typename OptionMap>
boost::any GetOrEmpty(OptionMap const& options, std::string_view option_name) {
auto it = options.find(std::string{option_name});
return it == options.end() ? boost::any{} : it->second;
return it == options.end() ? boost::any{} : GetAny(it->second);
}

} // namespace details
Expand Down

0 comments on commit 2d3ce09

Please sign in to comment.