It’s really nice being able to implicitly construct a juce::var from types that it supports, e.g.
void setValue (juce::var value);
setValue ("Hello, World!");
setValue (123);
However, when you want to set a custom type for which you’ve specified a juce::VariantConverter, suddenly it’s not so nice:
struct MyCoolClass{};
template<>
struct VariantConverter<MyCoolClass> {};
setValue (juce::VariantConverter<MyCoolClass>::toVar (myCoolObject));
It’d be really nice if there were a templated constructor for juce::var that used juce::VariantConverter internally, and perhaps an operator T() as well?
template<typename T>
var::var (const T& value)
{
*this = VariantConverter<T>::toVar (value);
}
template<typename T>
T var::operator T() const
{
return VariantConverter<T>::fromVar (*this);
}