Debian Codegraph @

yo/advancedtemplates/examples/errcode/category/errorcondition

raw
1 namespace std {
2 class error_condition {
3 int value_;
4 std::error_category *cat_;
5 public:
6 error_condition()
7 : error_code(0, std::generic_category()) {}
8
9 error_condition(int e, const std::error_category& c)
10 : value_(e), cat_(&c) {}
11
12 template<class E> error_condition(E e)
13 { *this = make_error_condition(e);}
14
15 template<class E> error_condition& operator=(E e)
16 { *this = make_error_condition(e); }
17
18 void assign(int e, const std::error_category& c)
19 { value_ = e; cat_ = &c; }
20
21 void clear()
22 { *this = std::error_condition(); }
23
24 explicit operator bool() const
25 { return value_ != 0; }
26
27 int value() const
28 { return value_; }
29
30 const std::error_category& category() const
31 { return cat_; }
32
33 std::string message() const
34 { return cat_->message(value_); }
35 };
36
37 bool operator==(const error_condition& a, const error_condition &b)
38 { return a.value() == b.value() && &a.category() == &b.category();}
39
40
41
42
43