Skip to content

Commit 8d2eca1

Browse files
committed
Remove c++11 deprecated ptr_fun and bind2nd
2 parents 69986b1 + c313025 commit 8d2eca1

File tree

10 files changed

+21
-65
lines changed

10 files changed

+21
-65
lines changed

src/aodv/model/aodv-rqueue.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ RequestQueue::DropPacketWithDst (Ipv4Address dst)
7676
for (std::vector<QueueEntry>::iterator i = m_queue.begin (); i
7777
!= m_queue.end (); ++i)
7878
{
79-
if (IsEqual (*i, dst))
79+
if (i->GetIpv4Header ().GetDestination () == dst)
8080
{
8181
Drop (*i, "DropPacketWithDst ");
8282
}
8383
}
84-
m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (),
85-
std::bind2nd (std::ptr_fun (RequestQueue::IsEqual), dst)), m_queue.end ());
84+
auto new_end = std::remove_if (m_queue.begin (), m_queue.end (),
85+
[&](const QueueEntry& en) { return en.GetIpv4Header ().GetDestination () == dst; });
86+
m_queue.erase (new_end, m_queue.end ());
8687
}
8788

8889
bool

src/aodv/model/aodv-rqueue.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,6 @@ class RequestQueue
271271
uint32_t m_maxLen;
272272
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
273273
Time m_queueTimeout;
274-
/**
275-
* Determine if queue matches a destination address
276-
* \param en The queue entry
277-
* \param dst The destination IPv4 address
278-
* \returns true if the queue entry matches the destination address
279-
*/
280-
static bool IsEqual (QueueEntry en, const Ipv4Address dst)
281-
{
282-
return (en.GetIpv4Header ().GetDestination () == dst);
283-
}
284274
};
285275

286276

src/dsdv/model/dsdv-packet-queue.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,14 @@ PacketQueue::DropPacketWithDst (Ipv4Address dst)
8888
for (std::vector<QueueEntry>::iterator i = m_queue.begin (); i
8989
!= m_queue.end (); ++i)
9090
{
91-
if (IsEqual (*i, dst))
91+
if (i->GetIpv4Header ().GetDestination () == dst)
9292
{
9393
Drop (*i, "DropPacketWithDst ");
9494
}
9595
}
96-
m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (),
97-
std::bind2nd (std::ptr_fun (PacketQueue::IsEqual), dst)), m_queue.end ());
96+
auto new_end = std::remove_if (m_queue.begin (), m_queue.end (), [&](const QueueEntry& en)
97+
{ return en.GetIpv4Header ().GetDestination () == dst; });
98+
m_queue.erase (new_end, m_queue.end ());
9899
}
99100

100101
bool

src/dsdv/model/dsdv-packet-queue.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,6 @@ class PacketQueue
291291
uint32_t m_maxLenPerDst;
292292
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
293293
Time m_queueTimeout;
294-
/**
295-
* Determine if queue entries are equal
296-
* \param en the queue entry
297-
* \param dst the IPv4 destination address
298-
* \returns true if the entry is for the destination address
299-
*/
300-
static bool IsEqual (QueueEntry en, const Ipv4Address dst)
301-
{
302-
return (en.GetIpv4Header ().GetDestination () == dst);
303-
}
304294
};
305295
}
306296
}

src/dsr/model/dsr-errorbuff.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ DsrErrorBuffer::DropPacketForErrLink (Ipv4Address source, Ipv4Address nextHop)
9696
for (std::vector<DsrErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i
9797
!= m_errorBuffer.end (); ++i)
9898
{
99-
if (LinkEqual (*i, link))
99+
if ((i->GetSource () == link[0]) && (i->GetNextHop () == link[1]))
100100
{
101101
DropLink (*i, "DropPacketForErrLink");
102102
}
103103
}
104-
m_errorBuffer.erase (std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (),
105-
std::bind2nd (std::ptr_fun (DsrErrorBuffer::LinkEqual), link)), m_errorBuffer.end ());
104+
105+
auto new_end = std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (), [&](const DsrErrorBuffEntry& en)
106+
{ return (en.GetSource () == link[0]) && (en.GetNextHop () == link[1]); });
107+
m_errorBuffer.erase (new_end, m_errorBuffer.end ());
106108
}
107109

108110
bool

src/dsr/model/dsr-errorbuff.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,6 @@ class DsrErrorBuffer
298298
uint32_t m_maxLen;
299299
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
300300
Time m_errorBufferTimeout;
301-
/**
302-
* Check if the send buffer entry is the same or not
303-
* \param en Buffer Entry
304-
* \param link Link description.
305-
* \return true if the entry is compatible with the link description (source and next hop)
306-
*/
307-
///
308-
static bool LinkEqual (DsrErrorBuffEntry en, const std::vector<Ipv4Address> link)
309-
{
310-
return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1]));
311-
}
312301
};
313302
/*******************************************************************************************************************************/
314303
} // namespace dsr

src/dsr/model/dsr-maintain-buff.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ DsrMaintainBuffer::DropPacketWithNextHop (Ipv4Address nextHop)
8585
NS_LOG_FUNCTION (this << nextHop);
8686
Purge ();
8787
NS_LOG_INFO ("Drop Packet With next hop " << nextHop);
88-
m_maintainBuffer.erase (std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (),
89-
std::bind2nd (std::ptr_fun (DsrMaintainBuffer::IsEqual), nextHop)), m_maintainBuffer.end ());
88+
89+
auto new_end = std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (), [&](const DsrMaintainBuffEntry& en)
90+
{ return en.GetNextHop () == nextHop; });
91+
m_maintainBuffer.erase (new_end, m_maintainBuffer.end ());
9092
}
9193

9294
bool

src/dsr/model/dsr-maintain-buff.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,6 @@ class DsrMaintainBuffer
483483
uint32_t m_maxLen;
484484
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
485485
Time m_maintainBufferTimeout;
486-
/// Verify if the maintain buffer is equal or not
487-
/// \param en The Entry to check
488-
/// \param nextHop The next hop to check
489-
/// \return true if an Entry next hop is equal to the function second parameter
490-
static bool IsEqual (DsrMaintainBuffEntry en, const Ipv4Address nextHop)
491-
{
492-
return (en.GetNextHop () == nextHop);
493-
}
494486
};
495487
/*******************************************************************************************************************************/
496488
} // namespace dsr

src/dsr/model/dsr-rsendbuff.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ DsrSendBuffer::DropPacketWithDst (Ipv4Address dst)
9191
for (std::vector<DsrSendBuffEntry>::iterator i = m_sendBuffer.begin (); i
9292
!= m_sendBuffer.end (); ++i)
9393
{
94-
if (IsEqual (*i, dst))
94+
if (i->GetDestination () == dst)
9595
{
9696
Drop (*i, "DropPacketWithDst");
9797
}
9898
}
99-
m_sendBuffer.erase (std::remove_if (m_sendBuffer.begin (), m_sendBuffer.end (),
100-
std::bind2nd (std::ptr_fun (DsrSendBuffer::IsEqual), dst)), m_sendBuffer.end ());
99+
auto new_end = std::remove_if (m_sendBuffer.begin (), m_sendBuffer.end (), [&](const DsrSendBuffEntry& en)
100+
{ return en.GetDestination () == dst; });
101+
m_sendBuffer.erase (new_end, m_sendBuffer.end ());
101102
}
102103

103104
bool

src/dsr/model/dsr-rsendbuff.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,6 @@ class DsrSendBuffer
259259

260260
uint32_t m_maxLen; ///< The maximum number of packets that we allow a routing protocol to buffer.
261261
Time m_sendBufferTimeout; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
262-
/**
263-
* Check if the send buffer entry is the same or not
264-
*
265-
* \param en SendBufferEntry
266-
* \param dst IPv4 address to check
267-
* \return true if the SendBufferEntry destination is the same,
268-
* false otherwise
269-
*/
270-
static bool IsEqual (DsrSendBuffEntry en, const Ipv4Address dst)
271-
{
272-
return (en.GetDestination () == dst);
273-
}
274262
};
275263
/*******************************************************************************************************************************/
276264
} // namespace dsr

0 commit comments

Comments
 (0)