Skip to content

Commit 5ec27df

Browse files
committed
Fix issue with std::function reflection on Windows.
1 parent a60a237 commit 5ec27df

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

include/nbind/TypeStd.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ template <int argCount>
4242
struct CallbackStructure {
4343
const StructureType placeholderFlag;
4444
const int arity;
45-
const TYPEID argType[argCount + 1];
45+
const TYPEID returnType;
46+
const TYPEID argType[argCount];
4647
};
4748

4849
template<typename ReturnType, typename... Args>
@@ -59,7 +60,7 @@ const CallbackStructure<sizeof...(Args)> Typer<std::function<ReturnType (Args...
5960
StructureType :: callback,
6061
sizeof...(Args),
6162
Typer<ReturnType>::makeID(),
62-
Typer<Args>::makeID()...
63+
{ Typer<Args>::makeID()... }
6364
};
6465

6566
} // namespace

src/reflect.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ External NBind :: queryType(
139139

140140
case StructureType :: callback:
141141
callbackSpec = static_cast<const CallbackStructure<1> *>(id.getStructure());
142-
rawTypePtr = callbackSpec->argType + 1;
142+
rawTypePtr = callbackSpec->argType;
143143
arity = callbackSpec->arity;
144144

145145
while(arity--) {
@@ -149,7 +149,7 @@ External NBind :: queryType(
149149

150150
result = outTypeDetail.call<External>(
151151
static_cast<unsigned char>(placeholderFlag),
152-
NBindID(callbackSpec->argType[0]),
152+
NBindID(callbackSpec->returnType),
153153
typeIdList
154154
);
155155

0 commit comments

Comments
 (0)