diff options
-rw-r--r-- | netfs/fuse/fuseAppBase.h | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/netfs/fuse/fuseAppBase.h b/netfs/fuse/fuseAppBase.h index d899e00..5cc8f7f 100644 --- a/netfs/fuse/fuseAppBase.h +++ b/netfs/fuse/fuseAppBase.h @@ -138,39 +138,34 @@ class DLL_PUBLIC FuseAppBase { static void fuseDestroy(void *); template <typename BFunc, typename IFunc, BFunc bfunc, typename ... Args> - static typename std::enable_if<!std::is_same<BFunc, IFunc>::value, int(*)(Args...)>::type getHelper(int(FuseAppBase::*)(Args...)) + static int(*getHelper(int(FuseAppBase::*)(Args...)))(Args...) { - return &helper<BFunc, bfunc, Args...>; - } - template <typename BFunc, typename IFunc, BFunc bfunc, typename ... Args> - static typename std::enable_if<std::is_same<BFunc, IFunc>::value, int(*)(Args...)>::type getHelper(int(FuseAppBase::*)(Args...)) - { - return nullptr; - } - template <typename Func, Func f, typename ... Args> - static int helper(Args ... a) - { - for (int t = 0; ; ++t) { - try { - fuseApp->beforeOperation(); - return (fuseApp->*f)(a...); - } - catch (const std::exception & ex) { - if (t < 10) { - if (int rtn = fuseApp->onError(ex)) { - return rtn; + if constexpr (!std::is_same<BFunc, IFunc>::value) { + return [](Args ... a) { + for (int t = 0; ; ++t) { + try { + fuseApp->beforeOperation(); + return (fuseApp->*bfunc)(a...); + } + catch (const std::exception & ex) { + if (t < 10) { + if (int rtn = fuseApp->onError(ex)) { + return rtn; + } + } + else { + fuseApp->logf(LOG_ERR, "Retries expired with %s calling %s", ex.what(), typeid(bfunc).name()); + return -EIO; + } + } + catch (...) { + fuseApp->logf(LOG_ERR, "Unknown exception calling %s", typeid(bfunc).name()); + return -EIO; } } - else { - fuseApp->logf(LOG_ERR, "Retries expired with %s calling %s", ex.what(), typeid(f).name()); - return -EIO; - } - } - catch (...) { - fuseApp->logf(LOG_ERR, "Unknown exception calling %s", typeid(f).name()); - return -EIO; - } + }; } + return nullptr; } template <typename Func, Func f, typename ... Args> static int internalHelper(Args ... a) |