Function recurses infinitely
CLion detects that the following function 'recurses infinitely'.
As far as I see, that's not the case as long as there are no reference cycles.
How will I get rid of this 'warning'?
This is on 2019.3
class recurse {
using value_type = std::variant<recurse, std::string>;
std::vector<value_type> values_;
public:
std::string to_string() { return to_string(values_); };
private:
std::string to_string(const std::vector<value_type>& values){
return std::accumulate(values.cbegin(), values.cend(), std::string{}, [this](const value_type& v) {
if (std::holds_alternative<recurse>(v)) {
return to_string(std::get<recurse>(v).values_);
} else {
return std::get<std::string>(v);
}
});
}
}
Please sign in to leave a comment.