From b9d50d53d83fc35c554ada0749ae84fc661feaf2 Mon Sep 17 00:00:00 2001 From: mikemirzayanov Date: Mon, 23 Jul 2018 19:39:02 +0300 Subject: [PATCH] Fixed compilation in g++ (for std=c++03) --- generators/bgen.cpp | 4 +--- generators/gen-bipartite-graph.cpp | 5 ++--- testlib.h | 19 ++++++++++++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/generators/bgen.cpp b/generators/bgen.cpp index ad82b6b..04a21db 100644 --- a/generators/bgen.cpp +++ b/generators/bgen.cpp @@ -15,8 +15,6 @@ using namespace std; int main(int argc, char* argv[]) { registerGen(argc, argv, 1); - - cout << rnd.next("[0000000001]{100}") << endl; - + println(rnd.next("[0000000001]{100}")); return 0; } diff --git a/generators/gen-bipartite-graph.cpp b/generators/gen-bipartite-graph.cpp index 1a07678..65839f7 100644 --- a/generators/gen-bipartite-graph.cpp +++ b/generators/gen-bipartite-graph.cpp @@ -58,10 +58,9 @@ int main(int argc, char* argv[]) pb[i] = i + 1; shuffle(pb.begin(), pb.end()); - cout << n << " " << m << " " << e.size() << endl; - + println(n, m, e.size()); forn(i, e.size()) - cout << pa[e[i].first] << " " << pb[e[i].second] << endl; + println(pa[e[i].first], pb[e[i].second]); return 0; } diff --git a/testlib.h b/testlib.h index e8edcbb..9b5335c 100644 --- a/testlib.h +++ b/testlib.h @@ -25,7 +25,7 @@ * Copyright (c) 2005-2018 */ -#define VERSION "0.9.19" +#define VERSION "0.9.20" /* * Mike Mirzayanov @@ -63,6 +63,7 @@ */ const char* latestFeatures[] = { + "Fixed compilation in g++ (for std=c++03)", "Batch of println functions (support collections, iterator ranges)", "Introduced rnd.perm(size, first = 0) to generate a `first`-indexed permutation", "Allow any whitespace in readInts-like functions for non-validators", @@ -173,6 +174,7 @@ const char* latestFeatures[] = { # define ON_WINDOWS # if defined(_MSC_VER) && _MSC_VER>1400 # pragma warning( disable : 4127 ) +# pragma warning( disable : 4146 ) # pragma warning( disable : 4458 ) # endif #else @@ -2236,6 +2238,7 @@ std::fstream tout; /* implementation */ +#if __cplusplus > 199711L || defined(_MSC_VER) template static std::string vtos(const T& t, std::true_type) { @@ -2274,6 +2277,18 @@ static std::string vtos(const T& t) { return vtos(t, std::is_integral()); } +#else +template +static std::string vtos(const T& t) +{ + std::string s; + static std::stringstream ss; + ss.str(std::string()); + ss << t; + ss >> s; + return s; +} +#endif template static std::string toString(const T& t) @@ -4462,6 +4477,7 @@ NORETURN void expectedButFound(TResult result, long double expected #endif +#if __cplusplus > 199711L || defined(_MSC_VER) template struct is_iterable { @@ -4649,3 +4665,4 @@ void println(const A& a, const B& b, const C& c, const D& d, const E& e, const F __testlib_print_one(g); std::cout << std::endl; } +#endif