diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-09-17 10:06:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-17 10:06:21 +0200 |
| commit | 94799223495b9842bca67e1a6ecf611cec3ee771 (patch) | |
| tree | 435f5b6adb6889462640b1456e684360cd7e495f /dev/lib/logic | |
| parent | 6789dd7d88a192e3f55b95798cb393e7d12f368a (diff) | |
| parent | fa4748e414e9494442f9bcde9c659d3951af19c0 (diff) | |
(SCL: v1.0.44) Merge pull request #1 from snu-systems-corp/dev
SCL: v1.0.44
Diffstat (limited to 'dev/lib/logic')
| -rw-r--r-- | dev/lib/logic/opt.hpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/dev/lib/logic/opt.hpp b/dev/lib/logic/opt.hpp index 442756c..137460c 100644 --- a/dev/lib/logic/opt.hpp +++ b/dev/lib/logic/opt.hpp @@ -20,6 +20,7 @@ namespace ocl count = err - okay + 1, }; + template <typename char_type = char> struct opt final { explicit opt(const return_type& return_type) @@ -27,11 +28,23 @@ namespace ocl { } - opt& expect(const char* input) + template <typename ErrorHandler> + opt& try_or_handle(const char_type* input) { if (m_ret == return_type::err) { - throw std::runtime_error(input); + ErrorHandler handler; + handler(input ? input : ""); + } + + return *this; + } + + opt& try_or_throw(const char_type* input) + { + if (m_ret == return_type::err) + { + throw std::runtime_error(input ? input : ""); } return *this; |
