Macro to template

Hello, I have this macro, that expands to some methods of my class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define POPULAR_COMBO_FILTRO_COM_BASE(classeTabela)                    																   \
void VisualizadorLogsFrame::PopularComboFiltroCom ## classeTabela (bool limparTexto) { 																   \
	long from, to;													   																   \
	m_cbxDetalhe->GetSelection(&from, &to);							   																   \
	wxString conteudoCombo = m_cbxDetalhe->GetValue();				   																   \
	m_cbxDetalhe->Clear();                                             																   \
	if (!limparTexto) {												   																   \
		m_cbxDetalhe->SetValue(conteudoCombo);						   																   \
		m_cbxDetalhe->SetSelection(from, to);						   																   \
	}																   																   \
    int pos = 0;													   																   \
    for (list<classeTabela*>::iterator linha = m_lista ## classeTabela ->begin(); linha != m_lista ## classeTabela ->end(); linha++) { \
    	wxIntClientData* idInfo = new wxIntClientData();			   																   \
    	idInfo->m_valor = (*linha)->m_id;							   																   \
		wxString nome = (*linha)->m_name;							   																   \
		if ( (m_cbxDetalhe->GetValue().size() == 0) || (nome.MakeUpper().Find(m_cbxDetalhe->GetValue().MakeUpper()) != wxNOT_FOUND) ) {
                    m_cbxDetalhe->Insert((*linha)->m_name, pos, idInfo); pos++;
                 };
       };
};


and I want to use a template instead of it. So I had translated it to:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    template<class CLASSE_TABELA> void PopularComboFiltroComNomeavel(list<CLASSE_TABELA*>* lista, bool limparTexto) {
    	long from, to;
    	m_cbxDetalhe->GetSelection(&from, &to);
    	wxString conteudoCombo = m_cbxDetalhe->GetValue();
    	m_cbxDetalhe->Clear();
    	if (!limparTexto) {
    		m_cbxDetalhe->SetValue(conteudoCombo);
    		m_cbxDetalhe->SetSelection(from, to);
    	}
        int pos = 0;
        for (list< CLASSE_TABELA *>::iterator linha = lista->begin(); linha != lista->end(); linha++) {
        	wxIntClientData* idInfo = new wxIntClientData();
        	idInfo->m_valor = (*linha)->m_id;
    		wxString nome = (*linha)->m_name;
    		if ( (m_cbxDetalhe->GetValue().size() == 0) || (nome.MakeUpper().Find(m_cbxDetalhe->GetValue().MakeUpper()) != wxNOT_FOUND) ) {
    			m_cbxDetalhe->Insert((*linha)->m_name, pos, idInfo); pos++;
    		};
    	};
    };


but I get a compile error on this line:
 
        for (list< CLASSE_TABELA *>::iterator linha = lista->begin(); linha != lista->end(); linha++) {


what am I doing wrong ? the error is:
VisualizadorLogsMain.h:174: error: expected ‘;’ before ‘linha’
VisualizadorLogsMain.h:174: error: ‘linha’ was not declared in this scope

-Nelson
Last edited on
template<class T>
¿where is `T' used? ¿did you intend template<class CLASSE_TABELA>?

In that case you need to typename list< CLASSE_TABELA *>::iterator linha
http://www.parashift.com/c++-faq-lite/nondependent-name-lookup-types.html
it worked! thanks!! :)
Topic archived. No new replies allowed.