Wraps function pointers, member functions and lambdas without ever allocating.
More...
template<typename FuncType>
struct SC::Function< FuncType >
Wraps function pointers, member functions and lambdas without ever allocating.
- Template Parameters
-
FuncType | Type of function to be wrapped (Lambda, free function or pointer to member function) |
- Note
- Size of lambdas or less than LAMBDA_SIZE (currently
2 * sizeof(void*)
).
If lambda is bigger than LAMBDA_SIZE
the constructor will static assert.
Example:
struct SomeClass
{
float memberValue = 2.0;
int memberFunc(float a) { return static_cast<int>(a + memberValue); }
};
struct SomeFunctor
{
float memberValue = 2.0;
int operator()(float a) { return static_cast<int>(a + memberValue); }
};
int someFunc(float a) { return static_cast<int>(a * 2); }
struct BigClass
{
};
void SC::FunctionTest::functionDocumentationSnippet()
{
SomeClass someClass;
Function<int(float)> func;
func = &someFunc;
func.bind<SomeClass, &SomeClass::memberFunc>(someClass);
func = [](float a) -> int { return static_cast<int>(a + 1.5); };
func = SomeFunctor{2.5};
}
#define SC_ASSERT_RELEASE(e)
Assert expression e to be true.
Definition: Assert.h:66
unsigned long long uint64_t
Platform independent (8) bytes unsigned int.
Definition: PrimitiveTypes.h:42