Hi, ALL,
I'm trying to simplify the writing of the for loop on the std::set.
This is what I'd like to have:
Obviously this code will fail as it1 and it2 are not defined outside the "if" blocks.
Is there an easy way to achieve this using C++98 (not C++11)?
Thank you.
I'm trying to simplify the writing of the for loop on the std::set.
This is what I'd like to have:
Code:
for( std::map<std::string,std::set<std::pair<std::string, double> > >::iterator it = m_score.begin(); it != m_score.end(); it++ )
{
wxString score = (*it).first;
if( score == "abc" || score == "def" )
{
std::set<std::pair<std::string,double> >::reverse_iterator it1 = (*it).second.rbegin();
std::set<std::pair<std::string,double> >::reverse_iterator it2 = (*it).second.rend();
}
else if( score == "ghi" || score == "jkl" )
{
std::set<std::pair<std::string,double> >::iterator it1 = (*it).second.begin();
std::set<std::pair<std::string,double> >::iterator it2 = (*it).second.end();
}
for( it1; it1 != it2; it1++ )
{
}
Is there an easy way to achieve this using C++98 (not C++11)?
Thank you.