I'm trying out the new range-v3 library (0.5.0, clang-7.1)
I'm traversing through a graph (bfs). Each node in the graph contains some vector data (std::vector<double>
). While traversing through the graph, I'm trying to create a concat_view
(which is concatenation of all the vectors).
I'm trying to store this concat_view
as a member variable of the graph traversal class. (default_bfs_visitor
from boost graph library, to be precise). So, upfront, I will not know how many vectors I'm going to encounter. I'm doing something like this.
struct bfs_visitor
{
private:
ranges::v3::any_view<double> mView;
public:
template<class Graph>
void finish_vertex (vertex_descriptor v, const Graph& g)
{
auto node = g[v];
std::vector<double>& data = dataForNode(node);
mView = ranges::v3::concat(mView, data);
}
};
After I'm done visiting the graph, I process the view to extract the required information.
As the type of mView
changes with each concat
operation, I'm unable to explicitly specify the type of mView
in the declaration.
This link says there's performance hit for any_view
. Is any_view
the only option?