From 20159f92a9ffad034172bd36d532e5ffd24c9ff2 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Sun, 8 Nov 2015 22:19:08 +0100 Subject: [PATCH] Replace GiNaC::ToString() with std::to_string(). And, while at it, also make CMake exercise the new real_imag exam introduced last week and document successful build with GCC-4.8. --- INSTALL | 2 +- check/CMakeLists.txt | 1 + ginac/CMakeLists.txt | 1 - ginac/Makefile.am | 2 +- ginac/archive.cpp | 3 +-- ginac/function.cppy | 3 +-- ginac/numeric.cpp | 3 +-- ginac/symbol.cpp | 5 +---- ginac/tostring.h | 41 ----------------------------------------- 9 files changed, 7 insertions(+), 54 deletions(-) delete mode 100644 ginac/tostring.h diff --git a/INSTALL b/INSTALL index e3fdb7bf..635ec4b6 100644 --- a/INSTALL +++ b/INSTALL @@ -20,7 +20,7 @@ TeX are necessary. Known to work with: - Linux on x86 and x86_64 using - - GCC 4.9, 5.1, and 5.2 + - GCC 4.8, 4.9, 5.1, and 5.2 - Clang 3.5.0 Known not to work with: diff --git a/check/CMakeLists.txt b/check/CMakeLists.txt index 5bf53a19..58f9736b 100644 --- a/check/CMakeLists.txt +++ b/check/CMakeLists.txt @@ -33,6 +33,7 @@ set(ginac_tests exam_misc exam_mod_gcd exam_cra + exam_real_imag bugme_chinrem_gcd factor_univariate_bug pgcd_relatively_prime_bug diff --git a/ginac/CMakeLists.txt b/ginac/CMakeLists.txt index ed6ac119..c872aad3 100644 --- a/ginac/CMakeLists.txt +++ b/ginac/CMakeLists.txt @@ -111,7 +111,6 @@ set(ginaclib_public_headers set(ginaclib_private_headers remember.h - tostring.h utils.h crc32.h hash_seed.h diff --git a/ginac/Makefile.am b/ginac/Makefile.am index 4c83ffd4..6f9fe748 100644 --- a/ginac/Makefile.am +++ b/ginac/Makefile.am @@ -9,7 +9,7 @@ libginac_la_SOURCES = add.cpp archive.cpp basic.cpp clifford.cpp color.cpp \ operators.cpp power.cpp registrar.cpp relational.cpp remember.cpp \ pseries.cpp print.cpp symbol.cpp symmetry.cpp tensor.cpp \ utils.cpp wildcard.cpp \ - remember.h tostring.h utils.h crc32.h hash_seed.h compiler.h \ + remember.h utils.h crc32.h hash_seed.h compiler.h \ parser/parse_binop_rhs.cpp \ parser/parser.cpp \ parser/parse_context.cpp \ diff --git a/ginac/archive.cpp b/ginac/archive.cpp index ffd8b58a..6a973775 100644 --- a/ginac/archive.cpp +++ b/ginac/archive.cpp @@ -27,7 +27,6 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "tostring.h" #include "version.h" #include @@ -272,7 +271,7 @@ std::istream &operator>>(std::istream &is, archive &ar) static const unsigned min_version = GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE; unsigned version = read_unsigned(is); if ((version > max_version) || (version < min_version)) - throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(min_version) + " thru " + ToString(max_version))); + throw (std::runtime_error("archive version " + std::to_string(version) + " cannot be read by this GiNaC library (which supports versions " + std::to_string(min_version) + " thru " + std::to_string(max_version))); // Read atoms unsigned num_atoms = read_unsigned(is); diff --git a/ginac/function.cppy b/ginac/function.cppy index f04b21b7..0876f9cf 100644 --- a/ginac/function.cppy +++ b/ginac/function.cppy @@ -34,7 +34,6 @@ #include "power.h" #include "archive.h" #include "inifcns.h" -#include "tostring.h" #include "utils.h" #include "hash_seed.h" #include "remember.h" @@ -878,7 +877,7 @@ unsigned function::find_function(const std::string &name, unsigned nparams) return serial; ++serial; } - throw (std::runtime_error("no function '" + name + "' with " + ToString(nparams) + " parameters defined")); + throw (std::runtime_error("no function '" + name + "' with " + std::to_string(nparams) + " parameters defined")); } /** Return the print name of the function. */ diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 2102e94b..209cb700 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -32,7 +32,6 @@ #include "ex.h" #include "operators.h" #include "archive.h" -#include "tostring.h" #include "utils.h" #include @@ -225,7 +224,7 @@ numeric::numeric(const char *s) // E to lower case term = term.replace(term.find("E"),1,"e"); // append _ to term - term += "_" + ToString((unsigned)Digits); + term += "_" + std::to_string((unsigned)Digits); // construct float using cln::cl_F(const char *) ctor. if (imaginary) ctorval = ctorval + cln::complex(cln::cl_I(0),cln::cl_F(term.c_str())); diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 4dd0691c..446a27fe 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -23,7 +23,6 @@ #include "symbol.h" #include "lst.h" #include "archive.h" -#include "tostring.h" #include "utils.h" #include "hash_seed.h" #include "inifcns.h" @@ -153,9 +152,7 @@ static const std::string& get_default_TeX_name(const std::string& name); std::string symbol::get_name() const { if (name.empty()) { - std::ostringstream s; - s << "symbol" << serial; - name = s.str(); + name = "symbol" + std::to_string(serial); } return name; } diff --git a/ginac/tostring.h b/ginac/tostring.h deleted file mode 100644 index 2ab90372..00000000 --- a/ginac/tostring.h +++ /dev/null @@ -1,41 +0,0 @@ -/** @file tostring.h - * - * Convert object to its string representation (output form). This is an - * internal header file. */ - -/* - * GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef GINAC_TOSTRING_H -#define GINAC_TOSTRING_H - -#include - -namespace GiNaC { - -template -std::string ToString(const T & t) -{ - std::ostringstream buf; - buf << t; - return buf.str(); -} - -} // namespace GiNaC - -#endif // ndef GINAC_TOSTRING_H -- 2.44.0