diff --git a/include/boost/graph/compressed_sparse_row_graph.hpp b/include/boost/graph/compressed_sparse_row_graph.hpp index 1a1cd674..59e8bb4a 100644 --- a/include/boost/graph/compressed_sparse_row_graph.hpp +++ b/include/boost/graph/compressed_sparse_row_graph.hpp @@ -43,6 +43,7 @@ #include #include #include +#include namespace boost { @@ -1284,22 +1285,51 @@ get_property(const BOOST_CSR_GRAPH_TYPE& g, Tag tag) return get_property_value(g.m_property, tag); } +template +struct csr_property_map_helper {}; +// Kind == void for invalid property tags, so we can use that to SFINAE out + template -struct property_map { - typedef typename detail::property_kind_from_graph::type kind; - typedef typename boost::mpl::if_< - boost::is_same, - vertex_all_t, - typename boost::mpl::if_< - boost::is_same, - edge_all_t, - graph_all_t>::type>::type all_tag; - typedef typename property_traits::type>::key_type key_type; - typedef typename property_traits::type>::value_type plist_type; - typedef transform_value_property_map, typename property_map::type> type; - typedef transform_value_property_map, typename property_map::const_type> const_type; +struct csr_property_map_helper { + typedef vertex_all_t all_tag; + typedef typename property_traits::type>::key_type key_type; + typedef VertexProperty plist_type; + typedef typename property_map::type all_type; + typedef typename property_map::const_type all_const_type; + typedef transform_value_property_map, all_type> type; + typedef transform_value_property_map, all_const_type> const_type; }; +template +struct csr_property_map_helper { + typedef edge_all_t all_tag; + typedef typename property_traits::type>::key_type key_type; + typedef EdgeProperty plist_type; + typedef typename property_map::type all_type; + typedef typename property_map::const_type all_const_type; + typedef transform_value_property_map, all_type> type; + typedef transform_value_property_map, all_const_type> const_type; +}; + +template +struct csr_property_map_helper { + typedef graph_all_t all_tag; + typedef BOOST_CSR_GRAPH_TYPE* key_type; + typedef GraphProperty plist_type; + typedef typename property_map::type all_type; + typedef typename property_map::const_type all_const_type; + typedef transform_value_property_map, all_type> type; + typedef transform_value_property_map, all_const_type> const_type; +}; + +template +struct property_map: + csr_property_map_helper< + BOOST_CSR_GRAPH_TYPE, + Tag, + typename detail::property_kind_from_graph + ::type> {}; + template typename property_map::type get(Tag tag, BOOST_CSR_GRAPH_TYPE& g) { @@ -1367,6 +1397,13 @@ struct property_map typedef typename BOOST_CSR_GRAPH_TYPE::forward_type::inherited_edge_properties::const_edge_map_type const_type; }; +template +struct property_map +{ + typedef boost::ref_property_map type; + typedef boost::ref_property_map const_type; +}; + template inline typed_identity_property_map get(vertex_index_t, const BOOST_CSR_GRAPH_TYPE&) @@ -1513,6 +1550,48 @@ put(edge_all_t, put(get(edge_all, g), e, val); } +template +inline typename property_map::type +get(graph_all_t, BOOST_CSR_GRAPH_TYPE& g) +{ + return typename property_map::type(g.m_property); +} + +template +inline typename property_map::const_type +get(graph_all_t, const BOOST_CSR_GRAPH_TYPE& g) +{ + return typename property_map::const_type(g.m_property); +} + +template +inline GraphProperty& +get(graph_all_t, + BOOST_CSR_GRAPH_TYPE& g, + BOOST_CSR_GRAPH_TYPE*) +{ + return g.m_property; +} + +template +inline const GraphProperty& +get(graph_all_t, + const BOOST_CSR_GRAPH_TYPE& g, + BOOST_CSR_GRAPH_TYPE*) +{ + return g.m_property; +} + +template +inline void +put(graph_all_t, + BOOST_CSR_GRAPH_TYPE& g, + BOOST_CSR_GRAPH_TYPE*, + const GraphProperty& val) +{ + g.m_property = val; +} + #undef BOOST_CSR_GRAPH_TYPE #undef BOOST_CSR_GRAPH_TEMPLATE_PARMS #undef BOOST_DIR_CSR_GRAPH_TYPE