I want to check if a data field is valid (valid means being not null and not filled with the default value)
Basically
return (!connector->IsNull(field_id) and connector->Get<type>Default(field_id, default_value))
But "type" can be one of many types (string, int64, etc...) so there are 5-6 different functions. I made a helper function for it and I'm trying to pass in the relevant GetDefault...
template<typename T> bool IsValidField(std::unique_ptr<Connector>& connector, const std::function<T(int, T)> &GetDefault, int field_id, T default_value){
return (!connector->IsNull(field_id) && connection->GetDefault(field_id, default_value) != default_value);
}
And I'm calling the helper function with....
IsValidField(connector, connector->GetStringWithDefault,20,"")
I get the error "error: reference to non-static member function must be called " because GetStringWithDefault isnt a static function, how do I fix this?
Alternately, is there a way of making it slightly less awkward?