Why does g ++ complain when using typedefs in graph_traits <>?

When I try to compile this code:

struct BasicVertexProperties
{
    Vect3Df position;
};

struct BasicEdgeProperties
{
};

template < typename VERTEXPROPERTIES, typename EDGEPROPERTIES >
class Graph
{
    typedef adjacency_list<
        setS, // disallow parallel edges
        vecS, // vertex container
        bidirectionalS, // directed graph
        property<vertex_properties_t, VERTEXPROPERTIES>,
        property<edge_properties_t, EDGEPROPERTIES>
    > GraphContainer;

    typedef graph_traits<GraphContainer>::vertex_descriptor Vertex;
    typedef graph_traits<GraphContainer>::edge_descriptor Edge;
};

g ++ complains of the following error in the line "typedef graph_traits <>":

error: type 'boost::graph_traits<boost::adjacency_list<boost::setS, boost::vecS, 
boost::bidirectionalS, boost::property<vertex_properties_t, VERTEXPROPERTIES, 
boost::no_property>, boost::property<edge_properties_t, EDGEPROPERTIES, 
boost::no_property>, boost::no_property, boost::listS> >' is not derived from type 
'Graph<VERTEXPROPERTIES, EDGEPROPERTIES>'

I found out that the compiler does not seem to know that my template parameters are types, but marking “typename” in front of them in the property definition does not help.

What's wrong? I just want to have the Graph template class to be able to use any properties that I like, derived from the basic property structures defined above, so I can have methods on this graph that work with basic properties.

+3
source share
1

:

    typedef graph_traits<GraphContainer>::vertex_descriptor Vertex;
    typedef graph_traits<GraphContainer>::edge_descriptor Edge;

:

    typedef typename graph_traits<GraphContainer>::vertex_descriptor Vertex;
    typedef typename graph_traits<GraphContainer>::edge_descriptor Edge;

, , vertex_descriptor , , GraphContainer ( ).

, , , -.

+7

Source: https://habr.com/ru/post/1708676/


All Articles