struct timeval tv;
if (gettimeofday(&tv, NULL) == 0)
{
- __time = (double)tv.tv_sec + (double)tv.tv_usec * 0.000001;
+ __time = double(tv.tv_sec) + double(tv.tv_usec) * 0.000001;
}
}
}
+static void __eat_whitespace(std::istream& in)
+{
+ while (in.good() && std::isspace(in.peek())) in.get();
+}
+
+
std::ostream& operator << (std::ostream& out, const std::string& str)
{
out << '"' << str.c_str() << '"';
std::istream& operator >> (std::istream& in, std::string& str)
{
- while (in.good() && std::isspace(in.peek())) in.get();
+ __eat_whitespace(in);
int c;
if (in.good() && (c = in.get()) == '"')
template <class T>
std::istream& operator >> (std::istream& in, std::vector<T>& vec)
{
- while (in.good() && std::isspace(in.peek())) in.get();
+ __eat_whitespace(in);
int c;
if (in.good() && (c = in.get()) == '{')
{
- while (in.good() && std::isspace(in.peek())) in.get();
- T t;
+ __eat_whitespace(in);
vec.clear();
while (in.good() && (c = in.get()) != '}')
{
if (c != ',') in.putback(c);
+
+ T t;
in >> t;
+ __eat_whitespace(in);
+
vec.push_back(t);
- while (in.good() && std::isspace(in.peek())) in.get();
}
}
return in;
}
+
template <class T>
bool __equals(const T& actual, const T& expected)
{