Closed jgallagher59701 closed 2 years ago
Basically, no. ‘auto’ in this case is telling the compiler to use type deduction. It is a way of making source code more readable by eliminating the long-winded type names that come with the Standard Template Library.
On Feb 16, 2022, at 15:54, kyang2014 @.***> wrote:
@kyang2014 commented on this pull request.
In D4Attributes.cc https://github.com/OPENDAP/libdap4/pull/178#discussion_r808522124:
- if (!rest.empty()) {
- // in this case, we are not looking for a leaf node, so descend the
- // attribute container hierarchy.
- for(auto i = d_attrs.begin(), e = d_attrs.end(); i != e; ++i) {
- if ((i)->name() == part && (i)->type() == attr_container_c) {
- (*i)->attributes()->erase(rest);
- }
- }
- }
- else {
- // now we have a leaf node, find and erase it.
- for(auto i = d_attrs.begin(), e = d_attrs.end(); i != e; ++i) {
- if ((*i)->name() == part) {
- delete *i; // delete the D4Attribute
- d_attrs.erase(i); // remove the D4Attribute* from the container
- } James, can "auto" pointer handle this "erase" case more gracefully? With an iterator, when you erase an element, you need to do something like this to avoid undefined behavior,
for (vector<Attribute >::iterator ira = (ircv)->attrs.begin(); ira != (ircv)->attrs.end();) { if(....) { delete (ira); ira = (*ircv)->attrs.erase(ira); } else { ++ira; } }
— Reply to this email directly, view it on GitHub https://github.com/OPENDAP/libdap4/pull/178#pullrequestreview-885240056, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7Q4KQEVS7VWC622IM3C43U3QTKBANCNFSM5OS66O2A. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.
-- James Gallagher @.***
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
5 Code Smells
71.7% Coverage
3.6% Duplication