Bug 2021 - Missing const qualifier in TopologyReader::Link::Attributes{Begin,End}()
Missing const qualifier in TopologyReader::Link::Attributes{Begin,End}()
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: topology-read
ns-3.21
PC All
: P5 trivial
Assigned To: Tommaso Pecorella
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-11-18 14:49 UTC by Nuno Cardoso
Modified: 2014-11-18 18:50 UTC (History)
1 user (show)

See Also:


Attachments
Added missing const qualifier to TopologyReader::Link::Attributes{Begin,End}() (1.45 KB, text/plain)
2014-11-18 14:49 UTC, Nuno Cardoso
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nuno Cardoso 2014-11-18 14:49:06 UTC
Created attachment 1923 [details]
Added missing const qualifier to TopologyReader::Link::Attributes{Begin,End}()

This patch fixes a problem I ran into when using AttributesBegin/End as follows:

<code>
    Ptr<TopologyReader> topoFile;
    //(...)
    TopologyReader::ConstLinksIterator iter = topoFile->LinksBegin();
    for (;iter != topoFile->LinksEnd(); iter++) {

        TopologyReader::Link::ConstAttributesIterator it = iter->AttributesBegin();
        for(;it != iter->AttributesEnd(); it++) {
            std::cout << "Key: " << it->first << " Value: "<< it->second << std::endl;
        }
    }
</code>


The resulting error was:


<code>
../scratch/SFL/topology.cc:60:82: error: passing ‘const ns3::TopologyReader::Link’ as ‘this’ argument of ‘ns3::TopologyReader::Link::ConstAttributesIterator ns3::TopologyReader::Link::AttributesBegin()’ discards qualifiers [-fpermissive]
         TopologyReader::Link::ConstAttributesIterator it = iter->AttributesBegin();
                                                                                  ^
../scratch/SFL/topology.cc:61:40: error: passing ‘const ns3::TopologyReader::Link’ as ‘this’ argument of ‘ns3::TopologyReader::Link::ConstAttributesIterator ns3::TopologyReader::Link::AttributesEnd()’ discards qualifiers [-fpermissive]
         for(;it != iter->AttributesEnd(); it++) {
</code>
Comment 1 Tommaso Pecorella 2014-11-18 18:50:40 UTC
changeset:   11063:3bfdbd13f978

Thanks Nuno :)