Template problem

M

mfabricius

Hi,

I am trying to compile somebody elses code (he is not available).
The code won't compile and I do not understand why

--SNIP--
//-----------------------------------------------------------------
// shell_t::rve
//-----------------------------------------------------------------
template <class V, class E, class F>
void shell_t<V, E, F>::rve(vert_t<V, E, F>* v1, edge_t<V, E, F>* e1)
{
....
//no complain
edge_t< V, E, F >* et;

//no complain
list< double >::iterator di;
//no complain
list< list<double> >::iterator ldi;
//no complain
list< list<double>* >::iterator ldip;

//no complain
list< edge_t< int, int, int > >::iterator let;

//COMPILE ERROR FOLLOWS NEXT LINE
list< edge_t< V, E, F >* >::iterator itr;

for(itr = edges.begin(); itr != edges.end(); itr++)
{
if ((*itr) == e1 || (*itr)->twin() == e1)
{
edges.erase(itr);
delete e1;
break;
}
}

--SNIP, SNIP---


Here the compiler error (g++-4.1, tried g++-3.95 as well):

he.cc: In member function 'void halfedge::shell_t<V, E,
F>::rve(halfedge::vert_t<V, E, F>*, halfedge::edge_t<V, E, F>*)':
he.cc:294: error: expected `;' before 'itr'
he.cc:296: error: 'itr' was not declared in this scope
he.cc:306: error: expected `;' before 'itr'


Any ideas?

Max
 
V

Victor Bazarov

I am trying to compile somebody elses code (he is not available).
The code won't compile and I do not understand why

--SNIP--
//-----------------------------------------------------------------
// shell_t::rve
//-----------------------------------------------------------------
template <class V, class E, class F>
void shell_t<V, E, F>::rve(vert_t<V, E, F>* v1, edge_t<V, E, F>* e1)
{
...
[..]
//COMPILE ERROR FOLLOWS NEXT LINE
list< edge_t< V, E, F >* >::iterator itr;

I think because 'edge_t' is a dependent type, 'list' is as well, and
the use of its member requires 'typename':

typename list said:
for(itr = edges.begin(); itr != edges.end(); itr++)
{
if ((*itr) == e1 || (*itr)->twin() == e1)
{
edges.erase(itr);
delete e1;
break;
}
}

--SNIP, SNIP---


Here the compiler error (g++-4.1, tried g++-3.95 as well):

he.cc: In member function 'void halfedge::shell_t<V, E,
he.cc:294: error: expected `;' before 'itr'
he.cc:296: error: 'itr' was not declared in this scope
he.cc:306: error: expected `;' before 'itr'


Any ideas?

Read about dependent names in the FAQ.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top