Bug 2021

Summary: Missing const qualifier in TopologyReader::Link::Attributes{Begin,End}()
Product: ns-3 Reporter: Nuno Cardoso <nunopcardoso>
Component: topology-readAssignee: Tommaso Pecorella <tommaso.pecorella>
Status: RESOLVED FIXED    
Severity: trivial CC: ns-bugs
Priority: P5    
Version: ns-3.21   
Hardware: PC   
OS: All   
Attachments: Added missing const qualifier to TopologyReader::Link::Attributes{Begin,End}()

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 :)