diff --git a/Applications/Utils/SWMMConverter/SWMMConverter.cpp b/Applications/Utils/SWMMConverter/SWMMConverter.cpp index a751557095de47532c491618ac3510d2281dacf7..4ca87d8970e8fbbe0c65acf5c37c9cd670c8754f 100644 --- a/Applications/Utils/SWMMConverter/SWMMConverter.cpp +++ b/Applications/Utils/SWMMConverter/SWMMConverter.cpp @@ -90,7 +90,7 @@ int writeMeshOutput(std::string const& input_file, addObjectsToMesh(*swmm, mesh, FileIO::SwmmObject::LINK, i); MeshLib::IO::VtuInterface vtkio(&mesh, 0, false); - std::string name(basename + BaseLib::tostring(i) + extension); + std::string name(basename + std::to_string(i) + extension); vtkio.writeToFile(name); } return 0; diff --git a/BaseLib/Algorithm.h b/BaseLib/Algorithm.h index a01a42ad5e121dfa7d279906d5adf1f9bfb7ecb6..8c8501c24989431694e5d66f74d5dfad487c9c65 100644 --- a/BaseLib/Algorithm.h +++ b/BaseLib/Algorithm.h @@ -13,11 +13,11 @@ #include <algorithm> #include <boost/optional.hpp> #include <cassert> +#include <string> #include <typeindex> #include <typeinfo> #include "Error.h" -#include "StringTools.h" namespace BaseLib { @@ -94,7 +94,7 @@ void insertIfTypeIndexKeyUniqueElseError(Map& map, Key const& key, if (!inserted.second) { // insertion failed, i.e., key already exists OGS_FATAL("{:s} Key `{:s}' already exists.", error_message, - tostring(key.hash_code())); + std::to_string(key.hash_code())); } } @@ -110,8 +110,7 @@ void insertIfKeyUniqueElseError(Map& map, Key const& key, Value&& value, auto const inserted = map.emplace(key, std::forward<Value>(value)); if (!inserted.second) { // insertion failed, i.e., key already exists - OGS_FATAL("{:s} Key `{:s}' already exists.", error_message, - tostring(key)); + OGS_FATAL("{:s} Key `{:s}' already exists.", error_message, key); } } @@ -130,14 +129,14 @@ void insertIfKeyValueUniqueElseError(Map& map, Key const& key, Value&& value, if (std::find_if(map.cbegin(), map.cend(), value_compare) != map.cend()) { OGS_FATAL("{:s} Value `{:s}' already exists.", error_message, - tostring(value)); + std::to_string(value)); } auto const inserted = map.emplace(key, std::forward<Value>(value)); if (!inserted.second) { // insertion failed, i.e., key already exists OGS_FATAL("{:s} Key `{:s}' already exists.", error_message, - tostring(key)); + std::to_string(key)); } } @@ -153,8 +152,15 @@ typename Map::mapped_type& getOrError(Map& map, Key const& key, auto it = map.find(key); if (it == map.end()) { - OGS_FATAL("{:s} Key `{:s}' does not exist.", error_message, - tostring(key)); + if constexpr (std::is_convertible<Key, std::string>::value) + { + OGS_FATAL("{:s} Key `{:s}' does not exist.", error_message, key); + } + else + { + OGS_FATAL("{:s} Key `{:s}' does not exist.", error_message, + std::to_string(key)); + } } return it->second; @@ -167,8 +173,15 @@ typename Map::mapped_type const& getOrError(Map const& map, Key const& key, auto it = map.find(key); if (it == map.end()) { - OGS_FATAL("{:s} Key `{:s}' does not exist.", error_message, - tostring(key)); + if constexpr (std::is_convertible<Key, std::string>::value) + { + OGS_FATAL("{:s} Key `{:s}' does not exist.", error_message, key); + } + else + { + OGS_FATAL("{:s} Key `{:s}' does not exist.", error_message, + std::to_string(key)); + } } return it->second; diff --git a/BaseLib/StringTools.cpp b/BaseLib/StringTools.cpp index 6f2118640e5f6e632a47d34b711b32a367d96a63..a881a25c0d37fd8195a622a4a454de5291e2abab 100644 --- a/BaseLib/StringTools.cpp +++ b/BaseLib/StringTools.cpp @@ -82,11 +82,6 @@ void simplify(std::string &str) ); } -std::string const& tostring(std::string const& value) -{ - return value; -} - std::string format(const char* format_str, ... ) { va_list args; diff --git a/BaseLib/StringTools.h b/BaseLib/StringTools.h index 62f9c5600264d2d7a965899de09873da9807acfb..23be7a0415e6ec9ef8c22f329b5b24347faf557a 100644 --- a/BaseLib/StringTools.h +++ b/BaseLib/StringTools.h @@ -72,14 +72,6 @@ void trim(std::string &str, char ch=' '); */ void simplify(std::string &str); -//! Method for handling conversion to string uniformly across all types and std::string; see std::string overload below. -template<typename T> std::string tostring(T const& value) -{ - return std::to_string(value); -} -//! \overload -std::string const& tostring(std::string const& value); - //! Returns a random string of the given length containing just a-z,A-Z,0-9 std::string randomString(std::size_t length);