std::variant
(Automatic Virtual Dispatch Using Template Method)¶
Overview¶
Much like std::variant (Manual Virtual Dispatch, Using std::visit)
Using template method in visitor
Virtual Access¶
#pragma once
struct get_temperature_visitor
{
double operator()(auto& s) // <--- abbreviated function template
{
return s.get_temperature();
}
};
static inline double get_temperature(Sensor& s)
{
return std::visit(get_temperature_visitor(), s);
}