From: Arnaud Giersch Date: Tue, 17 Oct 2017 20:04:38 +0000 (+0200) Subject: Remove const that was anyway ignored with a cast. X-Git-Tag: v3.18~414 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d7f6c787c779de32147c1e2b57aeb4d814c6a77e Remove const that was anyway ignored with a cast. --- diff --git a/include/xbt/string.hpp b/include/xbt/string.hpp index 7d665ff96e..ae6728ce78 100644 --- a/include/xbt/string.hpp +++ b/include/xbt/string.hpp @@ -55,7 +55,8 @@ struct string_data { * does not use refcouting/COW but has a small string optimization. */ XBT_PUBLIC_CLASS string : private string_data { - static const char NUL; + static char NUL; + public: // Types typedef std::size_t size_type; @@ -79,7 +80,7 @@ public: { if (size == 0) { string_data::len = 0; - string_data::data = const_cast(&NUL); + string_data::data = &NUL; } else { string_data::len = size; string_data::data = new char[string_data::len + 1]; @@ -87,7 +88,7 @@ public: string_data::data[string_data::len] = '\0'; } } - string() : string (const_cast(&NUL), 0) {} + string() : string(&NUL, 0) {} string(const char* s) : string(s, strlen(s)) {} string(string const& s) : string(s.c_str(), s.size()) {} string(string&& s) @@ -95,7 +96,7 @@ public: string_data::len = s.string_data::len; string_data::data = s.string_data::data; s.string_data::len = 0; - s.string_data::data = const_cast(&NUL); + s.string_data::data = &NUL; } string(std::string const& s) : string(s.c_str(), s.size()) {} @@ -180,7 +181,7 @@ public: void clear() { string_data::len = 0; - string_data::data = const_cast(&NUL); + string_data::data = &NUL; } bool equals(const char* data, std::size_t len) const diff --git a/src/xbt/string.cpp b/src/xbt/string.cpp index afc6445cee..7872cdc828 100644 --- a/src/xbt/string.cpp +++ b/src/xbt/string.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015. The SimGrid Team. +/* Copyright (c) 2015-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -17,7 +17,7 @@ namespace xbt { #if SIMGRID_HAVE_MC -const char string::NUL = '\0'; +char string::NUL = '\0'; #endif