任意の型のリストをコピーするジェネリック メソッドを書きたいと思います。私のコード:
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;
};
メソッドの呼び出し:
var list_a : list of uint;
gen list_a;
var list_b : list of uint;
list_b = copy_list(list_a);
エラー:
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(); };
copy_list
さらに、以下を使用してメソッドを定義するときにもエラーが発生しlist of untyped
ます。
Error: 'list_a' is of type 'list of uint', while expecting
type 'list of untyped'.
リストをコピーするための一般的なメソッドを書くのを手伝ってもらえますか? 助けてくれてありがとう