I would like to write a generic method that copies list of any type. My code:
copy_list(in_list : list of rf_type) : list of rf_type is {
var out_list : list of rf_type;
gen out_list keeping { it.size() == in_list.size(); };
for each (elem) in in_list {
out_list[index] = elem.unsafe();
};
result = out_list;
};
The method's call:
var list_a : list of uint;
gen list_a;
var list_b : list of uint;
list_b = copy_list(list_a);
The error:
ERR_GEN_NO_GEN_TYPE: Type 'list of rf_type' is not generateable
(it is not a subtype of any_struct) at line ...
gen out_list keeping { it.size() == in_list.size(); };
In addition, there is an error also when defining the method copy_list
using list of untyped
:
Error: 'list_a' is of type 'list of uint', while expecting
type 'list of untyped'.
Can you please help to write a generic method to copy list? Thank you for any help
Aucun commentaire:
Enregistrer un commentaire