Commit 463dfbb4 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Merge branch 'simplify-shared-any' into 'master'

Remove boost::any wrapper around std::shared_ptr

See merge request count0/graph-tool!28
parents 42e857bc 4c8a80b5
Pipeline #634 passed with stage
in 308 minutes and 10 seconds
...@@ -150,7 +150,7 @@ public: ...@@ -150,7 +150,7 @@ public:
// Gets the encapsulated graph view. See graph_filtering.cc for details // Gets the encapsulated graph view. See graph_filtering.cc for details
boost::any get_graph_view() const; boost::any get_graph_view() const;
std::vector<boost::any>& get_graph_views() {return _graph_views;} std::vector<std::shared_ptr<void>>& get_graph_views() {return _graph_views;}
private: private:
...@@ -168,7 +168,7 @@ private: ...@@ -168,7 +168,7 @@ private:
edge_index_map_t _edge_index; edge_index_map_t _edge_index;
// this will hold an instance of the graph views at run time // this will hold an instance of the graph views at run time
std::vector<boost::any> _graph_views; std::vector<std::shared_ptr<void>> _graph_views;
// reverse and directed states // reverse and directed states
bool _reversed; bool _reversed;
......
...@@ -524,17 +524,15 @@ retrieve_graph_view(GraphInterface& gi, Graph& init) ...@@ -524,17 +524,15 @@ retrieve_graph_view(GraphInterface& gi, Graph& init)
auto& graph_views = gi.get_graph_views(); auto& graph_views = gi.get_graph_views();
if (index >= graph_views.size()) if (index >= graph_views.size())
graph_views.resize(index + 1); graph_views.resize(index + 1);
boost::any& gview = graph_views[index]; std::shared_ptr<void>& gview = graph_views[index];
std::shared_ptr<g_t>* gptr = boost::any_cast<std::shared_ptr<g_t>>(&gview); if (!gview)
if (gptr == 0)
{ {
std::shared_ptr<g_t> new_g = std::shared_ptr<g_t> new_g =
get_graph_ptr<g_t>(gi, init, get_graph_ptr<g_t>(gi, init,
std::is_same<g_t, GraphInterface::multigraph_t>()); std::is_same<g_t, GraphInterface::multigraph_t>());
gview = new_g; gview = new_g;
return new_g;
} }
return *gptr; return std::static_pointer_cast<g_t>(gview);
} }
} //graph_tool namespace } //graph_tool namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment