From 69815a366be5ca81185386d94268d7e7dcce94e3 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Mon, 18 May 2020 08:22:21 +0200 Subject: [PATCH] [C++20] Clean up using-declarations. Never write a using-declaration before #including another header file! --- doc/examples/archive1.cpp | 3 ++- doc/examples/compile1.cpp | 3 ++- doc/examples/compile2.cpp | 5 +++-- doc/examples/compile3.cpp | 3 ++- doc/examples/mystring.cpp | 3 ++- doc/tutorial/ginac.texi | 8 +++----- ginsh/ginsh.h | 8 ++------ ginsh/ginsh_lexer.lpp | 3 +++ ginsh/ginsh_parser.ypp | 3 +++ 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/examples/archive1.cpp b/doc/examples/archive1.cpp index 6361becc..cf55ee5a 100644 --- a/doc/examples/archive1.cpp +++ b/doc/examples/archive1.cpp @@ -3,8 +3,9 @@ */ #include -using namespace std; #include + +using namespace std; using namespace GiNaC; int main() diff --git a/doc/examples/compile1.cpp b/doc/examples/compile1.cpp index c63b9ca0..b92dc766 100644 --- a/doc/examples/compile1.cpp +++ b/doc/examples/compile1.cpp @@ -1,7 +1,8 @@ #include #include -using namespace std; #include + +using namespace std; using namespace GiNaC; /* diff --git a/doc/examples/compile2.cpp b/doc/examples/compile2.cpp index faff99cc..960bbed9 100644 --- a/doc/examples/compile2.cpp +++ b/doc/examples/compile2.cpp @@ -1,10 +1,11 @@ #include -using namespace std; #include -using namespace GiNaC; // Yes, we are using CUBA (should be installed on the system!) #include +using namespace std; +using namespace GiNaC; + /* * Demonstrates the use of compile_ex with the CUBA library. * diff --git a/doc/examples/compile3.cpp b/doc/examples/compile3.cpp index 993c3b9f..b92df53f 100644 --- a/doc/examples/compile3.cpp +++ b/doc/examples/compile3.cpp @@ -1,7 +1,8 @@ #include #include -using namespace std; #include + +using namespace std; using namespace GiNaC; /* diff --git a/doc/examples/mystring.cpp b/doc/examples/mystring.cpp index 56c844d2..640f81eb 100644 --- a/doc/examples/mystring.cpp +++ b/doc/examples/mystring.cpp @@ -4,9 +4,10 @@ #include #include #include -using namespace std; #include + +using namespace std; using namespace GiNaC; class mystring : public basic diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index 765c966e..1ba42151 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -6696,8 +6696,8 @@ expression a unique name: @example #include -using namespace std; #include +using namespace std; using namespace GiNaC; int main() @@ -7613,9 +7613,8 @@ product in a C++ @code{struct}: @example #include -using namespace std; - #include +using namespace std; using namespace GiNaC; struct sprod_s @{ @@ -8007,9 +8006,8 @@ as follows: #include #include #include -using namespace std; - #include +using namespace std; using namespace GiNaC; @end example diff --git a/ginsh/ginsh.h b/ginsh/ginsh.h index ffaf4e0d..973c6f0d 100644 --- a/ginsh/ginsh.h +++ b/ginsh/ginsh.h @@ -29,8 +29,6 @@ #include #include -using namespace std; - #ifdef HAVE_READLINE_READLINE_H extern "C" { #include @@ -49,10 +47,8 @@ extern "C" { #include #endif -using namespace GiNaC; - // yacc stack type -#define YYSTYPE ex +#define YYSTYPE GiNaC::ex // lex functions/variables extern int yyerror(const char *s); @@ -65,7 +61,7 @@ extern int num_files; extern char **file_list; // Table of all used symbols -typedef map sym_tab; +typedef std::map sym_tab; extern sym_tab syms; // Type of symbols to generate (real or complex) diff --git a/ginsh/ginsh_lexer.lpp b/ginsh/ginsh_lexer.lpp index bc008b4e..4218193e 100644 --- a/ginsh/ginsh_lexer.lpp +++ b/ginsh/ginsh_lexer.lpp @@ -38,6 +38,9 @@ #include "ginsh.h" #include "ginsh_parser.hpp" +using namespace std; +using namespace GiNaC; + #define YY_INPUT(buf, result, max_size) (result = ginsh_input(buf, max_size)) // Table of all used symbols diff --git a/ginsh/ginsh_parser.ypp b/ginsh/ginsh_parser.ypp index a18229e3..c76616d0 100644 --- a/ginsh/ginsh_parser.ypp +++ b/ginsh/ginsh_parser.ypp @@ -45,6 +45,9 @@ #include "ginsh.h" +using namespace std; +using namespace GiNaC; + #define YYERROR_VERBOSE 1 #ifdef HAVE_LIBREADLINE -- 2.50.0