EsoErik

Thursday, September 17, 2009

 

dereferencing a pointer to a member variable taken as an argument

To save myself time in the future, I'm posting a function I wrote that dereferences a pointer to a member variable taken as an argument.


void Parser::loadSymbolSets(SymbolSet Symbol::* symbolSet, const SymbolIdentifier* symbolSetsDef)

{
std::vector<Parser::Symbol*>::iterator symbol(symbols.begin());

const SymbolIdentifier* symbolSetDef(symbolSetsDef);
for(; symbol != symbols.end(); ++symbol)

{
for(;;)
{
if(*symbolSetDef == IdProdSep)

{
++symbolSetDef;
break;
}
if(*symbolSetDef == IdSeqSep)

{
throw std::string("Parser::loadSymbolSets(..): IdSeqSep encountered in symbol set definition array.");
}

((*symbol)->*symbolSet).insert(symbols[*symbolSetDef]);

++symbolSetDef;
}
}
}

Labels:


Archives

July 2009   August 2009   September 2009   October 2009   November 2009   December 2009   January 2010   September 2010   December 2010   January 2011   February 2011   April 2011   June 2011   August 2011   February 2012   June 2012   July 2012   August 2012   October 2012   November 2012   January 2014   April 2014   June 2014   August 2014   September 2014   October 2014   January 2015   March 2015   April 2015   June 2015   November 2015   December 2015   January 2016   June 2016   August 2016   January 2017   March 2017  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]