[PPL-devel] [GIT] ppl/ppl(master): Do not use `using namespace std'.
Roberto Bagnara
roberto.bagnara at bugseng.com
Sun Dec 21 18:59:12 CET 2014
Module: ppl/ppl
Branch: master
Commit: 364ef4de2a7f2f7a7091bc160cf2f043fb6c790b
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=364ef4de2a7f2f7a7091bc160cf2f043fb6c790b
Author: Roberto Bagnara <roberto.bagnara at bugseng.com>
Date: Sun Dec 21 18:58:11 2014 +0100
Do not use `using namespace std'.
Fixes violations of rule UCGP1.L3 detected by ECLAIR.
---
demos/ppl_pips/ppl_pips.cc | 38 +++++++++++++++++++-------------------
utils/timings.cc | 10 ++++------
2 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/demos/ppl_pips/ppl_pips.cc b/demos/ppl_pips/ppl_pips.cc
index 6731411..e4f56d7 100644
--- a/demos/ppl_pips/ppl_pips.cc
+++ b/demos/ppl_pips/ppl_pips.cc
@@ -118,55 +118,55 @@ pip_display_sol(std::ostream& out,
const Parma_Polyhedra_Library::Variables_Set& vars,
Parma_Polyhedra_Library::dimension_type space_dimension,
int indent = 0) {
- using namespace std;
using namespace Parma_Polyhedra_Library::IO_Operators;
+
if (!pip) {
- out << setw(indent*2) << "" << "_|_" << endl;
+ out << std::setw(indent*2) << "" << "_|_" << std::endl;
}
else {
- for (PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator
+ for (PPL::PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator
i = pip->art_parameter_begin(),
i_end = pip->art_parameter_end();
i != i_end;
++i) {
- out << setw(indent*2) << "" << "Parameter "
- << Linear_Expression(Variable(space_dimension++))
- << " = " << *i << endl;
+ out << std::setw(indent*2) << "" << "Parameter "
+ << PPL::Linear_Expression(PPL::Variable(space_dimension++))
+ << " = " << *i << std::endl;
}
- const Constraint_System &constraints = pip->constraints();
+ const PPL::Constraint_System& constraints = pip->constraints();
const bool constraints_empty = constraints.empty();
if (!constraints_empty) {
- out << setw(indent*2) << "" << "if ";
- for (Constraint_System::const_iterator
+ out << std::setw(indent*2) << "" << "if ";
+ for (PPL::Constraint_System::const_iterator
cs_begin = constraints.begin(),
cs_end = constraints.end(),
i = cs_begin; i != cs_end; ++i) {
out << ((i == cs_begin) ? "" : " and ") << *i;
}
- out << " then" << endl;
+ out << " then" << std::endl;
}
- const PIP_Decision_Node* const decision_node_p = pip->as_decision();
+ const PPL::PIP_Decision_Node* const decision_node_p = pip->as_decision();
if (decision_node_p) {
pip_display_sol(out, decision_node_p->child_node(true),
parameters, vars, space_dimension, indent+1);
- out << setw(indent*2) << "" << "else" << endl;
+ out << std::setw(indent*2) << "" << "else" << std::endl;
pip_display_sol(out, decision_node_p->child_node(false),
parameters, vars, space_dimension, indent+1);
}
else {
- const PIP_Solution_Node* const solution_node_p = pip->as_solution();
- out << setw(indent*2 + (constraints_empty ? 0 : 2)) << "" << "{";
- for (Variables_Set::const_iterator
+ const PPL::PIP_Solution_Node* const solution_node_p = pip->as_solution();
+ out << std::setw(indent*2 + (constraints_empty ? 0 : 2)) << "" << "{";
+ for (PPL::Variables_Set::const_iterator
v_begin = vars.begin(),
v_end = vars.end(),
i = v_begin; i != v_end; ++i) {
out << ((i == v_begin) ? "" : " ; ")
- << solution_node_p->parametric_values(Variable(*i));
+ << solution_node_p->parametric_values(PPL::Variable(*i));
}
- out << "}" << endl;
+ out << "}" << std::endl;
if (!constraints_empty) {
- out << setw(indent*2) << "" << "else" << endl;
- out << setw(indent*2 + 2) << "" << "_|_" << endl;
+ out << std::setw(indent*2) << "" << "else" << std::endl;
+ out << std::setw(indent*2 + 2) << "" << "_|_" << std::endl;
}
}
}
diff --git a/utils/timings.cc b/utils/timings.cc
index 7986cdd..b18ea0d 100644
--- a/utils/timings.cc
+++ b/utils/timings.cc
@@ -41,8 +41,6 @@ site: http://bugseng.com/products/ppl/ . */
# include <sys/resource.h>
#endif
-using namespace std;
-
#ifdef PPL_HAVE_TIMEVAL
// To save the time when start_clock is called.
static struct timeval saved_ru_utime;
@@ -53,7 +51,7 @@ start_clock() {
#if PPL_HAVE_DECL_GETRUSAGE && defined(PPL_HAVE_TIMEVAL)
struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage) != 0) {
- cerr << "getrusage failed: " << strerror(errno) << endl;
+ std::cerr << "getrusage failed: " << strerror(errno) << std::endl;
exit(1);
}
else {
@@ -63,11 +61,11 @@ start_clock() {
}
void
-print_clock(ostream& s) {
+print_clock(std::ostream& s) {
#if PPL_HAVE_DECL_GETRUSAGE && defined(PPL_HAVE_TIMEVAL)
struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage) != 0) {
- cerr << "getrusage failed: " << strerror(errno) << endl;
+ std::cerr << "getrusage failed: " << strerror(errno) << std::endl;
exit(1);
}
else {
@@ -96,7 +94,7 @@ print_clock(ostream& s) {
}
assert(csecs >= 0 && csecs < 100 && secs >= 0);
const char fill_char = s.fill();
- s << secs << "." << setfill('0') << setw(2) << csecs;
+ s << secs << "." << std::setfill('0') << std::setw(2) << csecs;
s.fill(fill_char);
}
#else
More information about the PPL-devel
mailing list