funchelpers: Support traits for non-member functions
[quassel.git] / src / common / funchelpers.h
index 6c7aeb6..c56cdb9 100644 (file)
@@ -29,27 +29,36 @@ namespace detail {
 
 // Primary template
 template<typename Func>
-struct FuncHelper : public FuncHelper<decltype(&Func::operator())> {};
+struct FuncHelper : public FuncHelper<decltype(&Func::operator())>
+{};
 
-// Overload for member function with const call operator
-template<typename C, typename R, typename ...Args>
-struct FuncHelper<R(C::*)(Args...) const> : public FuncHelper<R(C::*)(Args...)> {};
-
-// Overload for member function with non-const call operator
-template<typename C, typename R, typename ...Args>
-struct FuncHelper<R(C::*)(Args...)> {
-    using ClassType = C;
+// Overload for free function
+template<typename R, typename... Args>
+struct FuncHelper<R(*)(Args...)>
+{
     using FunctionType = std::function<R(Args...)>;
     using ReturnType = R;
     using ArgsTuple = std::tuple<Args...>;
 };
 
+// Overload for member function with non-const call operator
+template<typename C, typename R, typename... Args>
+struct FuncHelper<R(C::*)(Args...)> : public FuncHelper<R(*)(Args...)>
+{
+    using ClassType = C;
+};
+
+// Overload for member function with const call operator
+template<typename C, typename R, typename... Args>
+struct FuncHelper<R(C::*)(Args...) const> : public FuncHelper<R(C::*)(Args...)>
+{};
+
 /// @endcond
 
-}  // detail
+}  // namespace detail
 
 /**
  * Provides traits for the given callable.
  */
 template<typename Callable>
-using MemberFunction = detail::FuncHelper<Callable>;
+using FunctionTraits = detail::FuncHelper<Callable>;