Open Irallia opened 1 year ago
I have double-checked this and variant<..., string_view, ...>
is indeed not comparable with string_view
. So if you want comparison, you would need to compare with bio::io::var_io::info_element_value_type{"INS"}
which is arguably not very nice.
The workaround you chose is also very valid, and probably what I would recommend, too!
However, I see another problem with the code:
for (auto & info : rec.info()) {
if (info.id != "SVTYPE") continue;
if(auto* s = std::get_if<std::string_view>(&info.value)) {
std::string alt = "<" + std::string{*s} + ">";
rec.alt() = {alt};
}
}
writer.push_back(rec);
I think you are using the default records, which means that alt
is std::vector<std::string_view>
. You are assigning a std::string
to this within the inner if-statement. That string goes out-of-scope at the end of the if-statement, so the string_view is "dangling" when you push the record to the writer.
You can fix this by defining alt
in the same scope that you call push_back()
... but if you do bigger changes to the record, it is always recommended to create a deep record instead.
The current main-branch has easy-to-use preset for this.
fails with the following error:
My current solution is now: