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

  • Home
  • SEARCH
  • 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 988689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:40:25+00:00 2026-05-16T05:40:25+00:00

I am getting an error in Xcode when using templates in C++. Can someone

  • 0

I am getting an error in Xcode when using templates in C++. Can someone tell me what is wrong?

The first version reports an error in Xcode, but not in Visual Studio.

// Version 1: Error in Xcode, but not Visual Studio
template<typename LengthT, typename VertexT> 
int MyGraphAlgorithm(...arguments omitted...)
{
  using namespace boost;

  typedef property<vertex_distance_t, LengthT> VertextProperties_t;
  typedef adjacency_list<vecS, vecS, directedS, VertextProperties_t> Graph;
  // In next line Xcode reports: "error: expected `;' before 'vertexInitial'"
  graph_traits<Graph>::vertex_descriptor vertexInitial(100);
}

The second has no error. The difference is the use of the template parameter LengthT in a templated typedef.

// Version 2: No error in Xcode or Visual Studio
template<typename LengthT, typename VertexT> 
int MyGraphAlgorithm(...arguments omitted...)
{
  using namespace boost;

  // In the following line, LengthT has been changed to int
  typedef property<vertex_distance_t, int> VertextProperties_t;
  typedef adjacency_list<vecS, vecS, directedS, VertextProperties_t> Graph;
  graph_traits<Graph>::vertex_descriptor  vertexInitial(100);
}
  • 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-16T05:40:26+00:00Added an answer on May 16, 2026 at 5:40 am

    The reason for the error is that the compiler has no clue what graph_traits<Graph>::vertex_descriptor is. Is it a static member or a type? If it’s a type then you must say so:

    typename graph_traits<Graph>::vertex_descriptor
    

    The reason the compiler isn’t smart enough to figure it out on its own is because LengthT is a template parameter. It can be anything, and so at the time of template declaration the compiler can’t tell what its value is going to be, and the typedef is thus ambiguous.

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

Sidebar

Related Questions

I'm getting the following error in Xcode 3.2.1 on Snow Leopard 10.6.2 whenever I
I am getting duplicate error in my xcode while build and run I have
I'm getting error while using replace in an update statement in sql server 2008.
I am getting an error in Xcode that says whatEverVariable is undeclared This is
I'm able to do a distribution build using xcode 3.4 but in Xcode 4.2
Ever since I added this async request, I'm getting an xcode error of Sending
Today I experienced a very strange behavior with my XCode (using Version 4.2, iOS
I'm getting the following error in xcode. error for object 0x4e18d00: pointer being freed
I'm using XCode 3.2.6. I'd like to make my game work for earlier version
I'm getting an error in XCode: multiple methods named 'setEnabled' found with mismatched result,

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.