-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.h
46 lines (39 loc) · 828 Bytes
/
error.h
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
#ifndef ERROR_H
#define ERROR_H
#include <vector>
#include <string>
#include <functional>
#include <iostream>
namespace amps
{
class error
{
std::ostream &stream_;
public:
error(std::ostream &stream) :
stream_(stream)
{
}
error() :
stream_(std::cerr)
{
}
template <typename T, typename... Ts>
void log(const T &msg, const Ts... msgs)
{
if constexpr (sizeof...(Ts) > 0) {
stream_ << msg;
log(msgs...);
}
else {
stream_ << msg << std::endl;
}
}
template <typename... Ts>
void critical(const Ts... msgs)
{
log("Error: ", msgs...);
}
};
}
#endif // ERROR_H