Replace some C++98isms with C++11isms #453

Closed
opened 2026-10-05 04:21:52 +02:00 by adam · 2 comments
Owner

Notably we can now use range based for loops, eg:

            int count = 0;
            for (auto network : m_pUser->GetNetworks()) {
                for (auto chan : network->GetChans()) {
                    chan->ClearBuffer();
                    count++;
                }
            }

as opposed to the old style:

const vector<CIRCNetwork*>& vNetworks = m_pUser->GetNetworks();
            vector<CIRCNetwork*>::const_iterator networkIter;
            for (networkIter = vNetworks.begin(); networkIter != vNetworks.end(); ++networkIter) {
                const vector<CChan*>& vChans = (*networkIter)->GetChans();
                vector<CChan*>::const_iterator chanIter;
                for (chanIter = vChans.begin(); chanIter != vChans.end(); ++chanIter) {
                    (*chanIter)->ClearBuffer();
                    count++;
                }
            }
Notably we can now use range based for loops, eg: ``` c++ int count = 0; for (auto network : m_pUser->GetNetworks()) { for (auto chan : network->GetChans()) { chan->ClearBuffer(); count++; } } ``` as opposed to the old style: ``` c++ const vector<CIRCNetwork*>& vNetworks = m_pUser->GetNetworks(); vector<CIRCNetwork*>::const_iterator networkIter; for (networkIter = vNetworks.begin(); networkIter != vNetworks.end(); ++networkIter) { const vector<CChan*>& vChans = (*networkIter)->GetChans(); vector<CChan*>::const_iterator chanIter; for (chanIter = vChans.begin(); chanIter != vChans.end(); ++chanIter) { (*chanIter)->ClearBuffer(); count++; } } ``` <!-- github-sync-id:54653643 -->
adam closed this issue 2026-10-05 04:21:52 +02:00
Author
Owner

We've got a lot of C++11 related changes merged. Anything else on the wish list?

  • range-based for loops
  • override
  • nullptr

Loops were changed by hand, override & nullptr were added mostly with help of clang-modernize. Additionally, some auto's could be sprinkled here and there, but I think I'm not going to start systematically doing that. We can do such tweaks when we touch the respective code. Case closed for now?

We've got a lot of C++11 related changes merged. Anything else on the wish list? - range-based for loops - override - nullptr Loops were changed by hand, override & nullptr were added mostly with help of clang-modernize. Additionally, some auto's could be sprinkled here and there, but I think I'm not going to start systematically doing that. We can do such tweaks when we touch the respective code. Case closed for now? <!-- github-comment-id:76633402 -->
Author
Owner

Looks nice. Thanks!

Looks nice. Thanks! <!-- github-comment-id:76663700 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#453