summaryrefslogtreecommitdiffhomepage
path: root/dev/lib/logic
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-09-17 10:06:29 +0200
committerGitHub <noreply@github.com>2025-09-17 10:06:29 +0200
commitb06170354225f19271627df11525857fa34a38e7 (patch)
tree68c5ba79cf2fae57eeb1d708658a99b396a9defe /dev/lib/logic
parent6789dd7d88a192e3f55b95798cb393e7d12f368a (diff)
parent1c369ccc98734e72509509e9a5798a3aaa34dd70 (diff)
(OCL: v1.0.44) Merge pull request #5 from amlel-el-mahrouss/devv1.0.44
OCL: v1.0.44
Diffstat (limited to 'dev/lib/logic')
-rw-r--r--dev/lib/logic/opt.hpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/dev/lib/logic/opt.hpp b/dev/lib/logic/opt.hpp
index 442756c..70bce5e 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)
+ opt& expect(const char_type* input)
{
if (m_ret == return_type::err)
{
- throw std::runtime_error(input);
+ throw std::runtime_error(input ? input : "opt::error");
+ }
+
+ return *this;
+ }
+
+ template <typename ErrorHandler>
+ opt& expect_or_handle(const char_type* input)
+ {
+ if (m_ret == return_type::err)
+ {
+ ErrorHandler err_handler;
+ err_handler(input ? input : "opt::error");
}
return *this;