From: Frederic Suter Date: Thu, 18 May 2017 15:54:41 +0000 (+0200) Subject: attempt to get rid of all const_cast X-Git-Tag: v3.16~281^2~13 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c04b15f5346d042218b4fb8357cace04585e067b attempt to get rid of all const_cast --- diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index 7596ef6f1e..2c7c87d231 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -43,7 +43,7 @@ public: std::vector args = *args_; std::unique_ptr argv(new char*[argc + 1]); for (int i = 0; i != argc; ++i) - argv[i] = args[i].empty() ? const_cast(""): &args[i].front(); + argv[i] = args[i].empty() ? '\0' : &args[i].front(); argv[argc] = nullptr; code_(argc, argv.get()); } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 5a6483624c..4a2dd5479f 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -21,8 +21,8 @@ namespace routing { class BypassRoute { public: explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {} - const NetPoint* gw_src; - const NetPoint* gw_dst; + NetPoint* gw_src; + NetPoint* gw_dst; std::vector links; }; @@ -292,14 +292,14 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst, "calls to getRoute", src->cname(), dst->cname(), bypassedRoute->links.size()); if (src != key.first) - getGlobalRoute(src, const_cast(bypassedRoute->gw_src), links, latency); + getGlobalRoute(src, bypassedRoute->gw_src, links, latency); for (surf::LinkImpl* link : bypassedRoute->links) { links->push_back(link); if (latency) *latency += link->latency(); } if (dst != key.second) - getGlobalRoute(const_cast(bypassedRoute->gw_dst), dst, links, latency); + getGlobalRoute(bypassedRoute->gw_dst, dst, links, latency); return true; } XBT_DEBUG("No bypass route from '%s' to '%s'.", src->cname(), dst->cname()); diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 161300d350..63f2a6cdbe 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -492,7 +492,7 @@ static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector argv(new char*[argc + 1]); for (int i = 0; i != argc; ++i) - argv[i] = args[i].empty() ? const_cast(""): &args[i].front(); + argv[i] = args[i].empty() ? '\0' : &args[i].front(); argv[argc] = nullptr; int res = entry_point(argc, argv.get());