@@ -22,7 +22,7 @@ static void __timer_start()
22
22
struct timeval tv;
23
23
if (gettimeofday(&tv, NULL) == 0)
24
24
{
25
- __time = ( double) tv.tv_sec + ( double) tv.tv_usec * 0.000001;
25
+ __time = double( tv.tv_sec) + double( tv.tv_usec) * 0.000001;
26
26
}
27
27
}
28
28
@@ -34,6 +34,12 @@ static double __timer_stop()
34
34
}
35
35
36
36
37
+ static void __eat_whitespace(std::istream& in)
38
+ {
39
+ while (in.good() && std::isspace(in.peek())) in.get();
40
+ }
41
+
42
+
37
43
std::ostream& operator << (std::ostream& out, const std::string& str)
38
44
{
39
45
out << '"' << str.c_str() << '"';
@@ -55,7 +61,7 @@ std::ostream& operator << (std::ostream& out, const std::vector<T>& vec)
55
61
56
62
std::istream& operator >> (std::istream& in, std::string& str)
57
63
{
58
- while (in.good() && std::isspace(in.peek())) in.get( );
64
+ __eat_whitespace (in);
59
65
60
66
int c;
61
67
if (in.good() && (c = in.get()) == '"')
@@ -74,26 +80,29 @@ std::istream& operator >> (std::istream& in, std::string& str)
74
80
template <class T>
75
81
std::istream& operator >> (std::istream& in, std::vector<T>& vec)
76
82
{
77
- while (in.good() && std::isspace(in.peek())) in.get( );
83
+ __eat_whitespace (in);
78
84
79
85
int c;
80
86
if (in.good() && (c = in.get()) == '{')
81
87
{
82
- while (in.good() && std::isspace(in.peek())) in.get();
83
- T t;
88
+ __eat_whitespace(in);
84
89
vec.clear();
85
90
while (in.good() && (c = in.get()) != '}')
86
91
{
87
92
if (c != ',') in.putback(c);
93
+
94
+ T t;
88
95
in >> t;
96
+ __eat_whitespace(in);
97
+
89
98
vec.push_back(t);
90
- while (in.good() && std::isspace(in.peek())) in.get();
91
99
}
92
100
}
93
101
94
102
return in;
95
103
}
96
104
105
+
97
106
template <class T>
98
107
bool __equals(const T& actual, const T& expected)
99
108
{
0 commit comments