Skip to content

Commit f7e2426

Browse files
committed
Foundation: Make Function LAMBDA_SIZE user configurable
1 parent 690750c commit f7e2426

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Libraries/Foundation/Function.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ namespace SC
1515
///
1616
/// Example:
1717
/// \snippet Tests/Libraries/Foundation/FunctionTest.cpp FunctionMainSnippet
18-
template <typename FuncType>
18+
template <typename FuncType, int LAMBDA_SIZE = sizeof(void*) * 2>
1919
struct Function;
2020

21-
template <typename R, typename... Args>
22-
struct Function<R(Args...)>
21+
template <int LAMBDA_SIZE, typename R, typename... Args>
22+
struct Function<R(Args...), LAMBDA_SIZE>
2323
{
2424
private:
2525
enum class Operation
@@ -37,8 +37,6 @@ struct Function<R(Args...)>
3737
OperationFunction operation;
3838
};
3939

40-
static const int LAMBDA_SIZE = sizeof(void*) * 2;
41-
4240
const VTable* vtable;
4341

4442
union
@@ -57,7 +55,7 @@ struct Function<R(Args...)>
5755
/// @brief Constructs an empty Function
5856
Function()
5957
{
60-
static_assert(sizeof(Function) == sizeof(void*) * 3, "Function Size");
58+
static_assert(sizeof(Function) == sizeof(void*) + LAMBDA_SIZE, "Function Size");
6159
vtable = nullptr;
6260
}
6361

0 commit comments

Comments
 (0)