-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.hh
63 lines (50 loc) · 1.13 KB
/
Utils.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef Utils_hh
#define Utils_hh
#include <cassert>
#include <cstdlib>
#include <getopt.h>
#include <string.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
/** \file
* Contains several useful includes, plus defines for errors and other
* utilities.
*/
/**
* Assert with message.
*/
#define _my_assert(b, s) { if (not (b)) { cerr << "ERROR: " << s << endl; assert(b); } }
/**
* Macro to specifically indicate when some code is unreachable,
* so that the compiler doesn't cry when using NDEBUG.
*/
#define _unreachable() { _my_assert(false, "Unreachable code reached."); }
/**
* C++11 to_string gives problems with Cygwin, so this is a replacement.
*/
inline string int_to_string (int i) {
ostringstream oss;
oss << i;
return oss.str();
}
/**
* C++11 stoi gives problems with Cygwin, so this is a replacement.
*/
inline int string_to_int (const string& s) {
istringstream iss(s);
int i;
iss >> i;
return i;
}
#endif