@@ -996,8 +996,10 @@ inline std::tuple<std::string, std::string, std::string> make_counting_iterator_
996996{
997997 std::string iterator_state_def_src = std::format (" struct {0} {{ {1} value; }};\n " , iterator_state_name, value_type);
998998 std::string advance_fn_def_src = std::format (
999- " extern \" C\" __device__ void {0}({1}* state, unsigned long long offset) {{\n "
1000- " state->value += offset;\n "
999+ " extern \" C\" __device__ void {0}(void* state, const void* offset) {{\n "
1000+ " auto* typed_state = static_cast<{1}*>(state);\n "
1001+ " auto offset_val = *static_cast<const unsigned long long*>(offset);\n "
1002+ " typed_state->value += offset_val;\n "
10011003 " }}" ,
10021004 advance_fn_name,
10031005 iterator_state_name);
@@ -1080,8 +1082,10 @@ inline std::tuple<std::string, std::string, std::string> make_reverse_iterator_s
10801082{
10811083 std::string iterator_state_src = std::format (" struct {0} {{ {1}* data; }};\n " , iterator_state_name, value_type);
10821084 std::string advance_fn_src = std::format (
1083- " extern \" C\" __device__ void {0}({1}* state, unsigned long long offset) {{\n "
1084- " state->data -= offset;\n "
1085+ " extern \" C\" __device__ void {0}(void* state, const void* offset) {{\n "
1086+ " auto* typed_state = static_cast<{1}*>(state);\n "
1087+ " auto offset_val = *static_cast<const unsigned long long*>(offset);\n "
1088+ " typed_state->data -= offset_val;\n "
10851089 " }}" ,
10861090 advance_fn_name,
10871091 iterator_state_name);
@@ -1341,8 +1345,9 @@ struct {0} {{
13411345
13421346 static constexpr std::string_view transform_it_advance_fn_src_tmpl = R"XXX(
13431347{3}
1344- extern "C" __device__ void {0}({1} *transform_it_state, unsigned long long offset) {{
1345- {2}(&(transform_it_state->base_it_state), offset);
1348+ extern "C" __device__ void {0}(void *transform_it_state, const void* offset) {{
1349+ auto* typed_state = static_cast<{1}*>(transform_it_state);
1350+ {2}(&(typed_state->base_it_state), offset);
13461351}}
13471352)XXX" ;
13481353
@@ -1420,7 +1425,7 @@ inline std::tuple<std::string, std::string, std::string> make_discard_iterator_s
14201425{
14211426 std::string state_def_src = std::format (" struct {0} {{ {1}* data; }};\n " , iterator_state_name, value_type);
14221427 std::string advance_fn_def_src = std::format (
1423- " extern \" C\" __device__ void {0}({1} * /*state*/, unsigned long long /*offset*/) {{\n "
1428+ " extern \" C\" __device__ void {0}(void * /*state*/, const void* /*offset*/) {{\n "
14241429 " }}" ,
14251430 advance_fn_name,
14261431 iterator_state_name);
0 commit comments