25 Dec, 2009, Omega wrote in the 1st comment:
Votes: 0
Good day all, and Merry Christmas!

I'm having a small little issue with a new piece of code I've been working on. And after I asked around, and no answers could be found, I figured it would be best to turn to the community as a whole for some simple help.

template<class var_type>void Remove(std::list<var_type *>&lst, var_type *entity) {
std::list<var_type *>::iterator where_it_is;

where_it_is = std::find(lst.begin(), lst.end(), entity);

if(where_it_is != lst.end()) {

Edit: Example usage:: Remove<DESCRIPTOR_DATA>(descriptor_list, d);

This is the code in question, the design behind this is a safe-remove function for a std::list.

As most know, std::lists on remove, remove all occasions of entity, and some versions of remove, if the entity isn't in the list when it is called, has a nice tendancy to explode. I think this issue is more compiler specific then anything. In anycase, I wrote this up, as well as several other little functions that fit my core design quite nicely.

They all have the same issue, and here it is:

Tools.h: In function void Daemon::Remove(std::list<var_type*, std::allocator<var_type*> >&, var_type*):
Tools.h:24: error: expected `;' before where_it_is
Tools.h:26: error: where_it_is was not declared in this scope

it has been suggested that std::list<var_type *>::iterator where_it_is; could of been using a std odd name,
and it was also thought that because var_type is a template<class var_type> that std::list may not except a template within, well, a template. However, varying docs on lists say it is possible (and even give examples) though I seem to explode with this.

So if anyone can lend a hand to figure out the error in question, please do. Oh, and before you say you need to see all the code before it, know that compiling this piece of code, will explode the same way, just with new line-numbers (or if you forget to include <list> )

Cheers, and thanks in advance for any help!
25 Dec, 2009, ocson wrote in the 2nd comment:
Votes: 0
Replace your declaration of where_it_is with

typename std::list<var_type *>::iterator where_it_is;

See the second part of this question for the reason why:

25 Dec, 2009, Omega wrote in the 3rd comment:
Votes: 0
Gah, thank you! Much appreciated, that fixed it alright!

Quick response, and thank you for the webpage, that's a big help too! Hopefully I won't have to post any more silly questions like this in the future.