summaryrefslogtreecommitdiffstats
path: root/src/FunctionRef.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/FunctionRef.h')
-rw-r--r--src/FunctionRef.h29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/FunctionRef.h b/src/FunctionRef.h
index 753d540a7..9c3a1369c 100644
--- a/src/FunctionRef.h
+++ b/src/FunctionRef.h
@@ -2,8 +2,7 @@
#pragma once
// Declared only so it can be partially specialized
-template <class Signature>
-class cFunctionRef;
+template <class Signature> class cFunctionRef;
/** A light-weight, type-erased reference to a function object.
@@ -32,16 +31,15 @@ would not be if using a `std::function` (See #3990 for implications of this).
- A `cFunctionRef` has no empty state but is non-owning and so is safe to call as
long as the referred object is still alive. */
-template <class Ret, class... Args>
-class cFunctionRef<Ret(Args...)>
+template <class Ret, class... Args> class cFunctionRef<Ret(Args...)>
{
-public:
+ public:
/** Construct from a function object. */
- template <class FunctionObject,
+ template <
+ class FunctionObject,
typename std::enable_if< // Don't disable the default copy constructor
!std::is_same<typename std::decay<FunctionObject>::type, cFunctionRef>::value,
- int>::type = 0
- >
+ int>::type = 0>
cFunctionRef(FunctionObject && a_FunctionObject)
{
// Store an opaque reference to the object.
@@ -52,16 +50,11 @@ public:
}
/** Call the referenced function object */
- Ret operator () (Args... a_Args)
- {
- return m_CallFunction(m_CallableData, std::forward<Args>(a_Args)...);
- }
-
-private:
+ Ret operator()(Args... a_Args) { return m_CallFunction(m_CallableData, std::forward<Args>(a_Args)...); }
+ private:
/** Function that performs the call. */
- template <class ObjectType>
- static Ret ObjectFunctionCaller(void * a_Callable, Args... a_Args)
+ template <class ObjectType> static Ret ObjectFunctionCaller(void * a_Callable, Args... a_Args)
{
// Convert opaque reference to the concrete type.
using ObjectPtr = typename std::add_pointer<ObjectType>::type;
@@ -71,7 +64,7 @@ private:
return Object(std::forward<Args>(a_Args)...);
}
- using cCallFunction = Ret(*)(void *, Args...);
+ using cCallFunction = Ret (*)(void *, Args...);
/** Type erased reference to a callable. */
void * m_CallableData;
@@ -79,5 +72,3 @@ private:
/** Function that knows how to call the type erased reference. */
cCallFunction m_CallFunction;
};
-
-