Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6054965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:12:42+00:00 2026-05-23T08:12:42+00:00

I am trying to create a class that expands on the behavior of the

  • 0

I am trying to create a class that expands on the behavior of the boost graph library. I would like my class to be a template, where the user supplies a type (class) which will be used to store properties at every vertex. That’s just background. I’m struggling with creating a more succinct typedef to use in defining my new class.

Based on other posts like this and this, I decided to define a struct that will contain the templated typedefs.

I’ll show two closely related approaches. I can’t figure out why the first typedef for GraphType seems to be working while the second for VertexType fails.

#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>

template <class VP>
struct GraphTypes
{
    typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VP > GraphType;
    typedef boost::graph_traits< GraphType >::vertex_descriptor VertexType;
};

int main()
{
    GraphTypes<int>::GraphType aGraphInstance;
    GraphTypes<int>::VertexType aVertexInstance;
    return 0;
}

Compiler output:

$ g++ -I/Developer/boost graph_typedef.cpp 
graph_typedef.cpp:8: error: type ‘boost::graph_traits<boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VP, boost::no_property, boost::no_property, boost::listS> >’ is not derived from type ‘GraphTypes<VP>’
graph_typedef.cpp:8: error: expected ‘;’ before ‘VertexType’
graph_typedef.cpp: In function ‘int main()’:
graph_typedef.cpp:14: error: ‘VertexType’ is not a member of ‘GraphTypes<int>’
graph_typedef.cpp:14: error: expected `;' before ‘aVertexInstance’

Same thing, just avoiding use of GraphType in the second typedef:

#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>

template <class VP>
struct GraphTypes
{
    typedef                      boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VP > GraphType;
    typedef boost::graph_traits< boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VP > >::vertex_descriptor VertexType;
};

int main()
{
    GraphTypes<int>::GraphType aGraphInstance;
    GraphTypes<int>::VertexType aVertexInstance;
    return 0;
}

Compiler output looks effectively the same:

g++ -I/Developer/boost graph_typedef.cpp 
graph_typedef.cpp:8: error: type ‘boost::graph_traits<boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VP, boost::no_property, boost::no_property, boost::listS> >’ is not derived from type ‘GraphTypes<VP>’
graph_typedef.cpp:8: error: expected ‘;’ before ‘VertexType’
graph_typedef.cpp: In function ‘int main()’:
graph_typedef.cpp:14: error: ‘VertexType’ is not a member of ‘GraphTypes<int>’
graph_typedef.cpp:14: error: expected `;' before ‘aVertexInstance’

Obviously the first compiler error is the root problem. I tried inserting typename in a few places with no success. I’m using gcc 4.2.1

How do I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:12:43+00:00Added an answer on May 23, 2026 at 8:12 am
    typedef typename boost::graph_traits<GraphType>::vertex_descriptor VertexType;
    //      ^^^^^^^^
    

    Should fix it, I don’t know where you tried to put it though.. you might have other problems I don’t see.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a User class that would store only hashed password class
I was trying to create an extension that could slice any array-like class (since
I am trying to create a utility class that accepts any type of POJO,
I am trying to create a Graph class that uses another class, the Vertex
I'm trying to create a class that inherits from ListBox and adding the property
I'm trying to create a class that manages the events of a combo box
I am trying to create a class that implements the IUnknown interface. I have
I'm trying to create a class that can instantiate arrays at runtime by giving
i am trying to create a class that will show the contents of a
I am trying to create a new class Dog that inherits via prototypical inheritance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.