I vote for #3 as it makes the intent instantaneously clear ( no need to ask yourself what's going on in the loops ) and fluent ( as long as you read it correctly )
even better, with ( hopefully ) c++17 range supportCode:auto sPDN = std::find_if( CPCRF::m_mPDN2RxSessionIds.begin(), CPCRF::m_mPDN2RxSessionIds.end(), [&]( auto const& keypair ) { return std::find( keypair.second.begin(), keypair.second.end(), sSessionId ) != keypair.second.end(); } ); if( sPDN != CPCRF::m_mPDN2RxSessionIds.end() ) { // ... }
Code:if( auto sPDN = std::find_if( CPCRF::m_mPDN2RxSessionIds, [&]( auto const& keypair ) { return std::find( keypair.second, sSessionId ); } ) ) { auto foundPDN = sPDN.front().first; // ... }




Reply With Quote
