From 9876391c6dcde1c59bb1bb35d9a0b4cab1e8ddf4 Mon Sep 17 00:00:00 2001 From: Ameya Deshpande Date: Tue, 21 Sep 2021 15:06:49 +0000 Subject: [PATCH] nix-vector-routing: Use `if constexpr ()` instead of `RunIf` Since ns-3 supports C++17 constructs now, we can make use of `if constexpr` as it evaluates the condition inside it only for that instantiation (distinction happens at compile time itself). Signed-off-by: Ameya Deshpande --- .../model/nix-vector-routing.cc | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/nix-vector-routing/model/nix-vector-routing.cc b/src/nix-vector-routing/model/nix-vector-routing.cc index e6b5e7654..d451a09e3 100644 --- a/src/nix-vector-routing/model/nix-vector-routing.cc +++ b/src/nix-vector-routing/model/nix-vector-routing.cc @@ -34,17 +34,6 @@ #include "nix-vector-routing.h" -/* RunIf code is a candidate for ns-3 core module */ -template -void RunIf (std::true_type, F&& f, Ts&&... ts ) -{ - f (std::forward(ts)...); -} -template -void RunIf (std::false_type, Xs&&...) -{ -} - namespace ns3 { NS_LOG_COMPONENT_DEFINE ("NixVectorRouting"); @@ -417,19 +406,12 @@ NixVectorRouting::GetAdjacentNetDevices (Ptr netDevice, PtrGetAddress (j); - bool isNetDeviceAddrLinkLocal = false; - RunIf (std::is_same{}, [&](Ipv6InterfaceAddress IfAddr, bool &isNetDeviceAddrLinkLocal) + if constexpr (!IsIpv4::value) { - if (IfAddr.GetScope () == Ipv6InterfaceAddress::LINKLOCAL) + if (netDeviceIfAddr.GetScope () == Ipv6InterfaceAddress::LINKLOCAL) { - isNetDeviceAddrLinkLocal = true; + continue; } - }, - netDeviceIfAddr, isNetDeviceAddrLinkLocal); - - if (isNetDeviceAddrLinkLocal) - { - continue; } for (uint32_t k = 0; k < remoteDeviceAddresses; ++k) {