, , .
Since I do not need this class TABLELOADERfor anything, but when calling this method, I made an explicit specialized specialization.
I agree that this is not exactly SFINAE, and it will not compile if I use a type that does not have loader->refresh()and is different from std::nullptr_t.
Here's what it looks like at the end:
(the code is simplified and probably has errors)
template<class TABLELOADER = std::nullptr_t>
class DiskFileFlush{
TABLELOADER *_loader;
public:
void process(){
notifyLoader(_loader);
}
template<class T>
static bool _notifyLoader(T *loader){
if (loader)
return loader->refresh();
return false;
}
static bool _notifyLoader(std::nullptr_t *){
return false;
}
};
source
share