06 Jun, 2010, Ix wrote in the 1st comment:
Votes: 0
Line 6…
T* GetElement( const std::string& name, const std::string& path = "./" )
{
if( name.empty() || path.empty() || m_list == NULL || m_list->empty())
return NULL;

for(std::vector<T*>::iterator i = m_list->begin();
i != m_list->end(); i++)
{
if((*i) != NULL)
if((*i)->GetName() == name)
if((*i)->GetPath() == path)
return (*i);
}

return NULL;
}


When I attempt to compile, gc++ returns this error:
object.h: In member function `T* ObjectManager<T>::GetElement(const std::string&, const std::string&)':
object.h:106: error: expected `;' before `i'
object.h:107: error: `i' was not declared in this scope


Did I write the line wrong in some way?
06 Jun, 2010, David Haley wrote in the 2nd comment:
Votes: 0
I'm assuming that you have template<T> above the function.

Try vector<typename T*> instead of vector<T*>.
06 Jun, 2010, Ix wrote in the 3rd comment:
Votes: 0
The actual object manager class itself has the template:

template <class T>
class ResourceManager


So trying to add a template to the function itself just returns an error that I'm shadowing my template declaration again.
06 Jun, 2010, David Haley wrote in the 4th comment:
Votes: 0
Ah, sure, that's fine then.

Did you try adding in 'typename' before 'T' in the iterator declaration?
06 Jun, 2010, Ix wrote in the 5th comment:
Votes: 0
I tried with 'class', and it told me that's no good. Now I try with 'typename' and it says that's invalid, so I assume you meant to type it as class T*.

But yeah that didn't work at all. When I type class T* I get this:

object.h: In member function `T* ObjectManager<T>::GetElement(const std::string&, const std::string&)':
object.h:109: error: using template type parameter `T' after `class'
object.h:109: error: template argument 1 is invalid
object.h:109: error: template argument 2 is invalid
object.h:109: error: expected initializer before `i'
object.h:110: error: `i' was not declared in this scope


I don't even know what the hell this thing's problem is.
06 Jun, 2010, David Haley wrote in the 6th comment:
Votes: 0
It's hard to know what's going on without seeing the code you're compiling. And no, I did not mean 'class'. Typename is a valid keyword, and in fact is meant specifically for this context, so if it's complaining about it, something else is happening. The fact that it's complaining about two template parameters when you should only have one is suspicious.

What version of g++ do you have?
06 Jun, 2010, Kayle wrote in the 7th comment:
Votes: 0
David Haley said:
What version of g++ do you have?


My server, I can answer that:

Quote
[kayle@valhalla home]$ g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v –with-pkgversion='Ubuntu 4.4.1-4ubuntu8' –with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs –enable-languages=c,c++,fortran,objc,obj-c++ –prefix=/usr –enable-shared –enable-multiarch –enable-linker-build-id –with-system-zlib –libexecdir=/usr/lib –without-included-gettext –enable-threads=posix –with-gxx-include-dir=/usr/include/c++/4.4 –program-suffix=-4.4 –enable-nls –enable-clocale=gnu –enable-libstdcxx-debug –enable-objc-gc –disable-werror –with-arch-32=i486 –with-tune=generic –enable-checking=release –build=x86_64-linux-gnu –host=x86_64-linux-gnu –target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8)
06 Jun, 2010, Ix wrote in the 8th comment:
Votes: 0
Found the solution…

for(typename std::vector<T*>::iterator i = m_list->begin();


Hooray for typename.
0.0/8