mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-20 14:58:54 +00:00
Provide better diagnostics for type/value mismatches.
This commit is contained in:
@@ -76,19 +76,49 @@ named_values::type named_values::get_type(const std::string &name) const
|
||||
}
|
||||
|
||||
nvbench::int64_t named_values::get_int64(const std::string &name) const
|
||||
try
|
||||
{
|
||||
return std::get<nvbench::int64_t>(this->get_value(name));
|
||||
}
|
||||
catch (std::exception &err)
|
||||
{
|
||||
throw std::runtime_error(fmt::format("{}:{}: Error looking up int64 value "
|
||||
"`{}`:\n{}",
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
name,
|
||||
err.what()));
|
||||
}
|
||||
|
||||
nvbench::float64_t named_values::get_float64(const std::string &name) const
|
||||
try
|
||||
{
|
||||
return std::get<nvbench::float64_t>(this->get_value(name));
|
||||
}
|
||||
catch (std::exception &err)
|
||||
{
|
||||
throw std::runtime_error(fmt::format("{}:{}: Error looking up float64 value "
|
||||
"`{}`:\n{}",
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
name,
|
||||
err.what()));
|
||||
}
|
||||
|
||||
const std::string &named_values::get_string(const std::string &name) const
|
||||
try
|
||||
{
|
||||
return std::get<std::string>(this->get_value(name));
|
||||
}
|
||||
catch (std::exception &err)
|
||||
{
|
||||
throw std::runtime_error(fmt::format("{}:{}: Error looking up string value "
|
||||
"`{}`:\n{}",
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
name,
|
||||
err.what()));
|
||||
}
|
||||
|
||||
void named_values::set_int64(std::string name, nvbench::int64_t value)
|
||||
{
|
||||
|
||||
@@ -52,6 +52,7 @@ private:
|
||||
std::string name;
|
||||
value_type value;
|
||||
};
|
||||
// TODO this should just be an unordered_map<string, value_type>.
|
||||
using storage_type = std::vector<named_value>;
|
||||
|
||||
storage_type m_storage;
|
||||
|
||||
Reference in New Issue
Block a user