yo/advancedtemplates/examples/errcode/category/defaulterrorcondition.cc
raw| 1 | //#define XERR |
| 2 | #include "category.ih" |
| 3 | |
| 4 | //def |
| 5 | std::error_condition Category::default_error_condition(int ev) |
| 6 | const noexcept |
| 7 | { |
| 8 | //= |
| 9 | // in real cases: ev represents CatErr values, also check for |
| 10 | // the upper limit, and each CatErr has its own Cond. |
| 11 | // (e.g. map[ev].conditionValue) |
| 12 | |
| 13 | //def |
| 14 | auto iter = s_map.find(as<CatErr>(ev)); |
| 15 | |
| 16 | return make_error_condition( |
| 17 | iter == s_map.end() ? Cond::NoCond : iter->second.cond |
| 18 | ); |
| 19 | } |
| 20 | //= |